getsockopt
getsockopt retrieves the value of the specified option for a socket.
Syntax
int getsockopt( SOCKET s, int level, int optname, char *optval, 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. Some values for the optname parameter are not supported. See the Remarks section below.
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 Value
0 (zero) if the function succeeds, SOCKET_ERROR if the function fails
Use WSAGetLastError to retrieve a specific error code.
Remarks
Some values for the optname parameter are not supported. The following sections list the options, by socket type, that are supported.
SOL_SOCKET level options:
-
SO_ACCEPTCONN
- SO_RCVBUF
- SO_SNDBUF
- SO_SND_DGRAMS (see Custom RTX64 socket options below)
- SO_RCV_DGRAMS (see Custom RTX64 socket options below)
- SO_BROADCAST
- SO_KEEPALIVE
- SO_LINGER
- SO_REUSEADDR
- SO_OOBINLINE
IPPROTO_TCP level options:
- TCP_NODELAY
- TCP_MAXRT
- TCP_PROVIDE_TIMESTAMPS (see Custom RTX64 socket options below)
- TCP_ACKNSEG (see Custom RTX64 socket options below)
- TCP_ACKDELAYTIME (see Custom RTX64 socket options below)
IPPROTO_IP level options:
- IP_DONTFRAGMENT
- IP_HDRINCL
- IP_TTL
- IP_TOS
- IP_MULTICAST_IF
- IP_MULTICAST_TTL
IPPROTO_IPV6 level options:
- IPV6_HDRINCL
- IPV6_V6ONLY
- IPV6_UNICAST_HOPS
- IPV6_MULTICAST_IF
- IPV6_MULTICAST_HOPS
- IPV6_MULTICAST_LOOP
NOTE: None of the options for the IPPROTO_RM, NSPROTO_IPX, SOL_APPLETALK, and SOL_IRLMP socket types are supported.
Option | Value | Description |
---|---|---|
SO_SND_DGRAMS | 0x100B | Maximum count of send datagrams on non-TCP socket (default 32) |
SO_RCV_DGRAMS | 0x100C | Maximum count of receive datagrams on non-TCP socket (default 32) |
TCP_PROVIDE_TIMESTAMPS | 13 | Turn ON/OFF Time stamp (default off) |
TCP_ACKDELAYTIME | 23 | Set ACK delay time - the delay period (in milliseconds) that the stack uses for delayed acknowledgements (ACKs). A value of zero disables delayed ACKs. Data segments are acknowledged immediately. Default value is 200. |
TCP_ACKNSEG | 24 | Turn ON/OFF the Selective Acknowledgments option in the TCP header. Default is ON. This option can only be changed prior to establishing a TCP connection. |
Requirements
Minimum Supported Version | RTX64 2013 |
Header | Winsock2.h |
Library | RtTcpip.lib |