COHERENT manpages

This page displays the COHERENT manpage for getsockopt() [Read a socket option].

List of available manpages
Index


getsockopt() -- Sockets Function (libsocket)

Read a socket option
#include <sys/types.h>
#include <sys/socket.h>
int getsockopt(socket, level, option, buffer, length)
int socket, level, option;
char *buffer;
int *length;

Function getsockopt() reads the options that are set on a socket.

socket  gives the  identifier of  the socket, as  returned by  the function
socket().

level gives  the level at which  the options are set.   To retrieve options
set  on the  socket  level, set  level  to SOL_SOCKET  whereas to  retrieve
options set the TCP level, set level to the number of the TCP protocol.

option gives the  number of the option whose setting  interests you.  For a
list of  options that are recognized  at the socket level,  see header file
<sys/socket.h>. Options  at other levels are  set by their respective
protocols.

buffer gives the address of  the buffer into which the retrieve information
will be  written.  length gives  the address of  an integer that  gives the
length of  buffer, in  bytes.  If  getsockopt() succeeds in  retrieving the
value of  the requested option,  it writes the  option into buffer  and re-
initializes  the int  to which  length  points to  give the  length of  the
material it wrote into buffer.

If all  goes well, getsockopt() returns zero.  If  something goes wrong, it
returns -1 and sets errno to one of the following values:

EBADF
     socket does not identify a valid socket.

ENOMEM
     The available user memory was insufficient to complete the operation.

ENOPROTOOPT
     option gives an unknown option.

ENOTSOCK
     socket identifies a file, not a socket.

See Also

libsocket,
setsockopt()