Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
setsockopt

The setsockopt() function shall set the option specified by the option_name argument, at the protocol level specified by the level argument, to the value pointed to by the option_value argument for the socket specified by the socket argument.

Functions

NMI_API sint8 setsockopt (SOCKET socket, uint8 u8Level, uint8 option_name, const void *option_value, uint16 u16OptionLen)
 

NMI_API sint8 setsockopt ( SOCKET  sock,
uint8  u8Level,
uint8  option_name,
const void *  option_value,
uint16  u16OptionLen 
)
The setsockopt() function shall set the option specified by the option_name
argument, at the protocol level specified by the level argument, to the value
pointed to by the option_value argument for the socket specified by the socket argument.
Parameters
[in]socketSocket handler.
[in]u8LevelProtocol level.
Supported protocol levels are SOL_SOCKET, SOL_SSL_SOCKET and SOL_RAW.
[in]option_nameOption to be set.
For protocol level SOL_SOCKET, the supported option names are:
SO_SET_UDP_SEND_CALLBACK
SO_TCP_KEEPALIVE
SO_TCP_KEEPIDLE
SO_TCP_KEEPINTVL
SO_TCP_KEEPCNT
For protocol level SOL_SSL_SOCKET, the supported option names are:
SO_SSL_BYPASS_X509_VERIF
SO_SSL_SNI
SO_SSL_ENABLE_SESSION_CACHING
SO_SSL_ENABLE_CERTNAME_VALIDATION
SO_SSL_ALPN
For protocol level SOL_RAW, the supported option names are:
SO_ICMP_FILTER
[in]option_valuePointer to user provided value.
[in]u16OptionLenLength of the option value in bytes. Refer to each option documentation for the required length.
Returns
The function shall return SOCK_ERR_NO_ERROR for successful operation and a negative value (indicating the error) otherwise.
Parameters
[in]socketSocket handler.
[in]u8LevelProtocol level.
Supported protocol levels are SOL_SOCKET and SOL_SSL_SOCKET.
[in]option_nameOption to be set.
For protocol level SOL_SOCKET, the supported option names are:
SO_SET_UDP_SEND_CALLBACK
SO_TCP_KEEPALIVE
SO_TCP_KEEPIDLE
SO_TCP_KEEPINTVL
SO_TCP_KEEPCNT
For protocol level SOL_SSL_SOCKET, the supported option names are:
SO_SSL_BYPASS_X509_VERIF
SO_SSL_SNI
SO_SSL_ENABLE_SESSION_CACHING
SO_SSL_ENABLE_SNI_VALIDATION
SO_SSL_ALPN
[in]option_valuePointer to user provided value.
[in]u16OptionLenLength of the option value in bytes. Refer to each option documentation for the required length.
Returns
The function shall return SOCK_ERR_NO_ERROR for successful operation and a negative value (indicating the error) otherwise.

References MAX_SOCKET, NULL, rawSetSockOpt(), tstrSetSocketOptCmd::sock, SOCK_ERR_INVALID, SOCK_ERR_INVALID_ARG, SOCK_ERR_NO_ERROR, SOCKET_CMD_SET_SOCKET_OPTION, SOCKET_REQUEST, SOL_RAW, SOL_SOCKET, SOL_SSL_SOCKET, sslSetSockOpt(), tstrSocket::u16SessionID, tstrSetSocketOptCmd::u16SessionID, tstrSetSocketOptCmd::u32OptionValue, and tstrSetSocketOptCmd::u8Option.

Referenced by demo_start(), set_alpn_list(), and sslConnect().