getsockopt

getsockopt retrieves an option associated with the specified socket.

Syntax

Copy
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:

IPPROTO_TCP level options:

IPPROTO_IP level options:

IPPROTO_IPV6 level options:

Note: None of the options for the IPPROTO_RM, NSPROTO_IPX, SOL_APPLETALK, and SOL_IRLMP socket types are supported.

Custom wRTOS socket options:

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