|
getsockopt retrieves the value of the specified option for a socket.
Syntax
int getsockopt( __in SOCKET s, __in int level, __in int optname, __in char *optval, __inout int *optlen );
Parameters
s
Socket descriptor of a currently open socket that uses the IP protocol.
level
Network layer. The values for this parameter are defined under setsockopt.
optname
Type of socket information to be returned. For detailed information on Winsock options, refer to Socket Options in the Winsock Reference (http://msdn.microsoft.com/en-us/library/ms740525(VS.85).aspx)
IMPORTANT! Some values for the optname parameter are not supported for the RT-TCP/IP version of the getsockopt and setsockopt functions. See Winsock Compatibility Issues for details.
optval
Pointer to a buffer to receive the option value. Its proper length depends on the type of information being returned, as specified in the optname field.
optlen
Size, in bytes, of the buffer at optval. Upon return, it contains the size of the option value retrieved, and ma be less than the value passed in.
Return Values
0 (zero) if the function succeeds, SOCKET_ERROR if the function fails
Use WSAGetLastError to retrieve a specific error code.