This function sets options for the specified socket.

Syntax

int setsockopt(
  SOCKET sock, 
  unsigned char u8Level, 
  unsigned char option_name, 
  const void *option_value, 
  unsigned short u16OptionLen
);

Parameters

sock
[in] Socket descriptor
u8Level
[in] Specifies the protocol level.
ValueDescription
SOL_SOCKET Socket option.
SOL_SSL_SOCKET SSL option.
option_name
[in] Specify the options.
ValueDescription
[u8Level = SOL_SOCKET] SO_SET_UDP_SEND_CALLBACK:
Enables / disables UDP callbacks.
[u8Level = SOL_SSL_SOCKET] SO_SSL_BYPASS_X509_VERIF:
Allows the socket to bypass the X509 certificate validation process.
[u8Level = SOL_SSL_SOCKET] SO_SSL_ENABLE_SNI_VALIDATION:
Enables SNI when connecting on the specified socket.
[u8Level = SOL_SSL_SOCKET] SO_SSL_SNI:
This option specifies the SNI hostname when connecting to the specified socket. The SNI hostname is specified in option_value.
option_value
[in] Specify the pointer of the setting value.
ValueDescription
[u8Level = SOL_SOCKET
option_name = SO_SET_UDP_SEND_CALLBACK]
Specifies a pointer to an int type setting value that indicates Enable / Disable.
1:ENABLE
0:DISABLE
[u8Level = SOL_SSL_SOCKET
option_name = SO_SSL_BYPASS_X509_VERIF]
Specifies a pointer to an int type setting value that indicates Enable / Disable.
1:ENABLE
0:DISABLE
[u8Level = SOL_SSL_SOCKET
option_name = SO_SSL_ENABLE_SNI_VALIDATION]
Specifies a pointer to an int type setting value that indicates Enable / Disable.
1:ENABLE
0:DISABLE
[u8Level = SOL_SSL_SOCKET
option_name = SO_SSL_SNI]
Specifies the SNI host name. The host name must be 63 characters or less. The host name must end with NULL. (It is possible to specify NULL in the 64th character. In this case, u16OptionLen is 63.)
u16OptionLen
[in] Specifies the length of the string. Used only when option_name = SO_SSL_SNI.
(Example) When option_value = "opticon.com", u16OptionLen is 11.

Return value

The following values will be returned.
ValueDescription
SOCK_ERR_NO_ERROR Succeeded
M2M_ERR_SLEEP_FAIL Initialize with SysWLANInit function.
Other than the above Failed

Remarks

Sets options for the specified socket.

Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Last updated: 2025/01/23