Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

16.12.1 Socket Option Functions

Here are the functions for examining and modifying socket options. They are declared in sys/socket.h.

— Function: int getsockopt (int socket, int level, int optname, void *optval, socklen_t *optlen-ptr)

The getsockopt function gets information about the value of option optname at level level for socket socket.

The option value is stored in a buffer that optval points to. Before the call, you should supply in *optlen-ptr the size of this buffer; on return, it contains the number of bytes of information actually stored in the buffer.

Most options interpret the optval buffer as a single int value.

The actual return value of getsockopt is 0 on success and -1 on failure. The following errno error conditions are defined:

EBADF
The socket argument is not a valid file descriptor.
ENOTSOCK
The descriptor socket is not a socket.
ENOPROTOOPT
The optname doesn't make sense for the given level.

— Function: int setsockopt (int socket, int level, int optname, void *optval, socklen_t optlen)

This function is used to set the socket option optname at level level for socket socket. The value of the option is passed in the buffer optval of size optlen.


 
 
  Published under the terms of the GNU General Public License Design by Interspire