getsockopt
getsockopt retrieves an option associated with the specified socket.
Syntax
int getsockopt(
[in] SOCKET s,
[in] int level,
[in] int optname,
[out] char *optval,
[in, out] int *optlen
);
Parameters
[in] s
The socket descriptor of a currently open socket that uses the IP protocol.
[in] level
The network layer. The values for this parameter are defined in setsockopt.
[in] optname
The socket information type to be returned. Some values for the optname parameter are not supported. See the Remarks section below.
[out] optval
A pointer to a buffer to receive the option value. Its proper length depends on the information type specified in optname being returned.
[in, out] optlen
A pointer to the size, in bytes, of the buffer at optval. Upon return, it contains the size of the retrieved option value and may be less than the value passed in.
Return Value
If the function succeeds, it returns 0 (zero). If the function fails, it returns SOCKET_ERROR. Call WSAGetLastError to retrieve a specific error code.
Remarks
Some values for the optname parameter are not supported. The following section lists the supported options by socket type.
SOL_SOCKET level options:
- SO_ACCEPTCONN
- SO_RCVBUF
- SO_SNDBUF
- SO_SND_DGRAMS (see Custom wRTOS socket options below)
- SO_RCV_DGRAMS (see Custom wRTOS 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 wRTOS socket options below)
- TCP_ACKNSEG (see Custom wRTOS socket options below)
- TCP_ACKDELAYTIME (see Custom wRTOS 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 |
The maximum count of send datagrams on a non-TCP socket (default 32). |
|
SO_RCV_DGRAMS |
0x100C |
The maximum count of receive datagrams on a non-TCP socket (default 32). |
|
TCP_PROVIDE_TIMESTAMPS |
13 |
Turn on/off Time Stamps (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 before establishing a TCP connection. |
Requirements
| Minimum supported version | Header | Library |
|---|---|---|
|
wRTOS 1.0 SDK |
winsock2.h |
RttcpipApi.lib |