Here are the functions for examining and modifying socket options. 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.
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 descriptor socket is not a socket. The optname doesn't make sense for the given level . 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 , which has size optlen .