Socket Option Id#

Silicon Labs vendor extensions#

These option ids are NOT part of the OSF / CMSIS IoT Socket specification. They are defined only for the SiWx91x BSD-backed IoT Socket wrapper and are non-portable. Code that needs to run against any other IoT Socket implementation must guard these option ids with #ifdefIOT_SOCKET_VENDOR_SILABS. The standard CMSIS IoT Socket option ids occupy values 1..5; the 0x1100+ range is reserved for Silicon Labs vendor extensions.

#define

Marker that the SiLabs vendor extensions below are available.

#define

Enable TLS on a stream socket (Silicon Labs vendor extension).

Macros#

#define

Non-blocking I/O (Set only, default = 0); opt_val = &nbio, opt_len = sizeof(nbio), nbio (integer): 0=blocking, non-blocking otherwise.

#define

Receive timeout in ms (default = 0); opt_val = &timeout, opt_len = sizeof(timeout)

#define

Send timeout in ms (default = 0); opt_val = &timeout, opt_len = sizeof(timeout)

#define

Keep-alive messages (default = 0); opt_val = &keepalive, opt_len = sizeof(keepalive), keepalive (integer): 0=disabled, enabled otherwise.

#define

Socket Type (Get only); opt_val = &socket_type, opt_len = sizeof(socket_type), socket_type (integer): IOT_SOCKET_SOCK_xxx.

Silicon Labs vendor extensions Documentation#

IOT_SOCKET_VENDOR_SILABS#

#define IOT_SOCKET_VENDOR_SILABS
Value:
1

Marker that the SiLabs vendor extensions below are available.


IOT_SOCKET_SO_SSL_ENABLE#

#define IOT_SOCKET_SO_SSL_ENABLE
Value:
0x1100

Enable TLS on a stream socket (Silicon Labs vendor extension).

Internally translated by the SiWx91x BSD-backed wrapper to setsockopt(socket, SOL_TCP, TCP_ULP, opt_val, opt_len). After the option is set, iotSocketConnect / iotSocketSend / iotSocketRecv operate over TLS transparently.

  • Call ordering#

    This option must be set on a freshly created stream socket before calling iotSocketConnect(). Setting it after connection has no effect because the TLS handshake is performed during connection.

  • Argument layout#

    • opt_val : pointer to a NUL-terminated TLS-version string. Accepted values are defined in socket.h:"tls", "tls_1_0", "tls_1_2", "tls_1_3".

    • opt_len : strlen(opt_val) + 1 (must include the trailing NUL).

  • Other TLS attributes (certificate index, SNI, ALPN, high-performance#

    flag, ...) are NOT exposed through this opt_id. They must be configured using the underlying setsockopt() call directly on the same fd.

  • Example#

    #ifdef IOT_SOCKET_VENDOR_SILABS
      const char tls_version[] = "tls_1_2";
      int32_t rc = iotSocketSetOpt(sock, IOT_SOCKET_SO_SSL_ENABLE,
                                   tls_version, sizeof(tls_version));
      if (rc < 0) { ... }
    #endif
      rc = iotSocketConnect(sock, server_ip, sizeof(server_ip), 443);
    

    Enable TLS on a stream socket. opt_val = TLS version string ("tls", "tls_1_0", "tls_1_2", "tls_1_3"); opt_len = strlen(opt_val) + 1. Must be set before iotSocketConnect().


Macro Definition Documentation#

IOT_SOCKET_IO_FIONBIO#

#define IOT_SOCKET_IO_FIONBIO
Value:
1

Non-blocking I/O (Set only, default = 0); opt_val = &nbio, opt_len = sizeof(nbio), nbio (integer): 0=blocking, non-blocking otherwise.


IOT_SOCKET_SO_RCVTIMEO#

#define IOT_SOCKET_SO_RCVTIMEO
Value:
2

Receive timeout in ms (default = 0); opt_val = &timeout, opt_len = sizeof(timeout)


IOT_SOCKET_SO_SNDTIMEO#

#define IOT_SOCKET_SO_SNDTIMEO
Value:
3

Send timeout in ms (default = 0); opt_val = &timeout, opt_len = sizeof(timeout)


IOT_SOCKET_SO_KEEPALIVE#

#define IOT_SOCKET_SO_KEEPALIVE
Value:
4

Keep-alive messages (default = 0); opt_val = &keepalive, opt_len = sizeof(keepalive), keepalive (integer): 0=disabled, enabled otherwise.


IOT_SOCKET_SO_TYPE#

#define IOT_SOCKET_SO_TYPE
Value:
5

Socket Type (Get only); opt_val = &socket_type, opt_len = sizeof(socket_type), socket_type (integer): IOT_SOCKET_SOCK_xxx.