1.2.1.2.29 getsockopt Function

C

int getsockopt(
    SOCKET s, 
    uint32_t level, 
    uint32_t option_name, 
    uint8_t * option_value, 
    uint32_t * option_length
);

Description

Various options can be set at the socket level. This function provides compatibility with BSD implementations.

Preconditions

None.

Parameters

ParametersDescription
sSocket descriptor returned from a previous call to socket.
levelOn which level the operation is to be performed: - IPPROTO_IP: applies to the IP protocol layer (not yet supported). - IPPROTO_TCP: applies to the TCP protocol layer. - SOL_SOCKET: applies to the socket layer. - IPPROTO_IPV6: applies to the IPv6 protocol layer (not yet supported). - IPPROTO_ICMPV6: applies to the ICMPv6 protocol layer (not yet supported).
option_nameThe name of the option to be set: -IPPROTO_TCP -TCP_NODELAY: specifies whether or not the stack should use the Nagle algorithm. - SOL_SOCKET - SO_LINGER: specifies what the stack should do with unsent data on close(). - SO_RCVBUF: specifies the size of the receive buffer (TCP only). - SO_SNDBUF: specifies the size of the transmit buffer.
option_valueFor all values of option_name, this is a pointer to the data, which in most cases is an integer. The only exception is SO_LINGER which points to a linger structure.
option_lengthThe size of the data pointed to by option_value.

Returns

  • 0 - If the function is successful.

  • -1 - If the function is unsuccessful.

Remarks

None.