getsockopt (Windows Sockets) (Compact 2013)
3/26/2014
This function retrieves a socket option.
Syntax
int getsockopt(
SOCKET s,
int level,
int optname,
char FAR* optval,
int FAR* optlen
);
Parameters
- s
[in] Descriptor identifying a socket.
level
[in] Level at which the option is defined; the supported levels include:
- optname
[in] Socket option for which the value is to be retrieved.
- optval
[out] Pointer to the buffer in which the value for the requested option is to be returned.
- optlen
[in, out] Pointer to the size of the optval buffer.
Return Value
If no error occurs, this function returns zero. If an error occurs, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
The following table shows the possible error codes.
Error code |
Description |
---|---|
WSANOTINITIALISED |
A successful WSAStartup call must occur before using this function. |
WSAENETDOWN |
The network subsystem has failed. |
WSAEFAULT |
One of the optval or optlen parameters is not a valid part of the user address space, or the optlen parameter is too small. |
WSAEINPROGRESS |
A blocking Winsock call is in progress, or the service provider is still processing a callback function. |
WSAEINVAL |
The level parameter is unknown or invalid. |
WSAENOPROTOOPT |
The option is unknown or unsupported by the indicated protocol family. |
WSAENOTSOCK |
The descriptor is not a socket. |
Remarks
This function retrieves the current value for a socket option associated with a socket of any type, in any state, and stores the result in optval. Options can exist at multiple protocol levels, but they are always present at the uppermost socket level. Options affect socket operations, such as the packet routing and out of band (OOB) data transfer.
The value associated with the selected option is returned in the buffer optval. The integer pointed to by optlen should originally contain the size of this buffer; on return, it will be set to the size of the value returned. For SO_LINGER, this will be the size of a linger structure. For most other options, it will be the size of an integer.
The application is responsible for allocating any memory space pointed to directly or indirectly by any of the parameters it specified.
If the option was never set with setsockopt (Windows Sockets), then getsockopt returns the default value for the option.
To view SOL_SOCKET options that are are supported for getsockopt, see SOL_SOCKET.
To view IPPROTO_TCP options that are are supported for getsockopt, see IPPROTO_TCP.
To view IPPROTO_IP options that are are supported for getsockopt, see IPPROTO_IP.
To view IPPROTO_IPv6 options that are are supported for getsockopt, see IPPROTO_IPV6.
To view SOL_IRLMP options that are are supported for getsockopt, see SOL_IRLMP.
Note
Windows Embedded Compact does not support Internetwork Packet Exchange (IPX).
The following list shows BSD options that are not supported in Windows Embedded Compact for getsockopt
- SO_RCVLOWAT
- SO_RCVTIME
- SO_SNDLOWAT
- SO_SNDTIMEO
- TCP_MAXSEG
Calling getsockopt with an unsupported option will result in an error code of WSAENOPROTOOPT being returned from WSAGetLastError.
Notes for IrDA Sockets
- The Af_irda.h header file must be explicitly included.
- Windows NT® and Windows 2000 will return WSAENETDOWN to indicate the underlying transceiver driver failed to initialize with the IrDA protocol stack.
- IrDA supports special socket options. For more information about these socket options, see SOL_IRLMP.
- Many SO level socket options are not meaningful to IrDA; only SO_LINGER and SO_DONTLINGER are specifically supported.
Requirements
Header |
winsock2.h |
Library |
Ws2.lib |
See Also
Reference
Socket Functions
bind (Windows Sockets)
closesocket
setsockopt (Windows Sockets)
socket (Windows Sockets)
WSAConnect
WSAEnumProtocols
WSAGetLastError
WSASetLastError
WSAStartup
linger