Returns the current parameters for the specified socket.
#include <sys/socket.h> #include <netinet/in.h> int getsockopt ( int s, int level, int optname, void *optval, size_t *optlen);
(IN) Specifies the socket file handle for which parameters are to be returned.
(IN) Specifies the protocol level at which the option resides with one of the following flags:
(IN) Specifies the option for the request. See one of the following:
(OUT) Points to the location of an option value. The data type of the option value matches the type used by the option requested with the optname parameter.
(IN/OUT) Points to a value describing the option’s length.
If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:
Options exist at either the socket level or the underlying protocol level. The following options are recognized at the socket level. Except as noted, each can be examined by calling getsockopt and set by calling the setsockopt function.