SiWx91x Sockets#

This section provides a reference to the SiWx91x chipset's socket API functions.

  • Note

    • SiWx91x Sockets support both synchronous and asynchronous socket operations.

Modules#

sl_si91x_socket_metadata_t

sl_si91x_sock_info_query_t

sl_si91x_socket_info_response_t

SiWx91x Socket Option Name

Typedefs#

typedef void(*
sl_si91x_socket_receive_data_callback_t)(uint32_t socket, uint8_t *buffer, uint32_t length, const sl_si91x_socket_metadata_t *firmware_socket_response)

Callback function reads asynchronous data from the socket.

typedef void(*
sl_si91x_socket_accept_callback_t)(int32_t socket, struct sockaddr *addr, uint8_t ip_version)

Callback functions for new asynchronous accepted connection.

typedef void(*
sl_si91x_socket_data_transfer_complete_handler_t)(int32_t socket, uint16_t length)

Callback function indicates data transfer status.

typedef void(*
sl_si91x_socket_select_callback_t)(fd_set *fd_read, fd_set *fd_write, fd_set *fd_except, int32_t status)

Callback function indicates asynchronous select request result.

typedef void(*
sl_si91x_socket_remote_termination_callback_t)(int socket, uint16_t port, uint32_t bytes_sent)

Callback function indicates termination of the remote socket.

Functions#

int
sl_si91x_socket(int family, int type, int protocol)

Creates a new socket.

int
sl_si91x_socket_async(int family, int type, int protocol, sl_si91x_socket_receive_data_callback_t callback)

Creates an asynchronous socket and registers the provided callback.

int
sl_si91x_setsockopt(int32_t socket, int level, int option_name, const void *option_value, socklen_t option_len)

Sets a specified socket option on the identified socket asynchronously.

int
sl_si91x_bind(int socket, const struct sockaddr *addr, socklen_t addr_len)

Assigns a local protocol address to a socket.

int
sl_si91x_listen(int socket, int max_number_of_clients)

Enables a socket to listen for remote connection requests in passive mode.

int
sl_si91x_accept(int socket, const struct sockaddr *addr, socklen_t addr_len)

Accepts a connection request from a remote peer.

int
sl_si91x_accept_async(int socket, sl_si91x_socket_accept_callback_t callback)

Accepts a connection request from the remote peer and registers a callback.

int
sl_si91x_connect(int socket, const struct sockaddr *addr, socklen_t addr_len)

Initiates a connection to a remote socket specified by the addr parameter.

int
sl_si91x_send(int socket, const uint8_t *buffer, size_t buffer_length, int32_t flags)

Sends the data to the remote peer on the given socket.

int
sl_si91x_send_async(int socket, const uint8_t *buffer, size_t buffer_length, int32_t flags, sl_si91x_socket_data_transfer_complete_handler_t callback)

Transmits one or more messages to a socket asynchronously.

int
sl_si91x_sendto(int socket, const uint8_t *buffer, size_t buffer_length, int32_t flags, const struct sockaddr *addr, socklen_t addr_len)

Transmits one or more messages to another socket.

int
sl_si91x_sendto_async(int socket, const uint8_t *buffer, size_t buffer_length, int32_t flags, const struct sockaddr *to_addr, socklen_t to_addr_len, sl_si91x_socket_data_transfer_complete_handler_t callback)

Transmits one or more messages to another socket asynchronously, and receives acknowledgement through the registered callback.

int
sl_si91x_send_large_data(int socket, const uint8_t *buffer, size_t buffer_length, int32_t flags)

Sends data that is larger than the Maximum Segment Size (MSS).

int
sl_si91x_recv(int socket, uint8_t *buffer, size_t bufferLength, int32_t flags)

Receives data from a connected socket.

int
sl_si91x_recvfrom(int socket, uint8_t *buffer, size_t buffersize, int32_t flags, struct sockaddr *fromAddr, socklen_t *fromAddrLen)

Receives data from an unconnected socket, typically a UDP socket.

int
sl_si91x_shutdown(int socket, int how)

Disables send or receive operations on a socket.

int
sl_si91x_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout, sl_si91x_socket_select_callback_t callback)

The sl_si91x_select() function is used to monitor multiple file descriptors for readiness to perform I/O operations.

void
sl_si91x_set_remote_termination_callback(sl_si91x_socket_remote_termination_callback_t callback)

Registers a callback for remote socket termination events.

sl_status_t
sl_si91x_get_socket_info(sl_si91x_socket_info_response_t *socket_info_response)

Retrieve information about currently opened sockets from the network stack.

int16_t
sl_si91x_get_socket_mss(int32_t socketIndex)

Retrieves the Maximum Segment Size (MSS) for a specific socket.

Typedef Documentation#

sl_si91x_socket_receive_data_callback_t#

sl_si91x_socket_receive_data_callback_t )(uint32_t socket, uint8_t *buffer, uint32_t length, const sl_si91x_socket_metadata_t *firmware_socket_response)

Callback function reads asynchronous data from the socket.

Parameters
N/Asocket

Socket ID.

N/Abuffer

Pointer to the buffer which stores the receiver data.

N/Alength

Buffer size.

N/Afirmware_socket_response

Pointer to sl_si91x_socket_metadata_t structure contains receiver packet metadata information. The metadata information consists of IP address (either, Ipv4 or IPV6), and port number.

The callback function reads asynchronous data from the socket when the sl_si91x_socket_async API is registered and called. The callback provides the following details: socket ID, pointer to the buffer which contains receiver data, size of the buffer, and metadata of the receiver packet (such as IP address, and port number).

Returns

  • N/A


Definition at line 99 of file components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_types.h

sl_si91x_socket_accept_callback_t#

sl_si91x_socket_accept_callback_t )(int32_t socket, struct sockaddr *addr, uint8_t ip_version)

Callback functions for new asynchronous accepted connection.

Parameters
N/Asocket

Socket ID of the accepted connection.

N/Aaddr

Pointer to struct sockaddr contains remote peer address.

N/Aip_version

IP version of the connection (for example, four bytes for IPv4, and six bytes for IPv6).

The callback provides paramenters for new accepted connection when the sl_si91x_accept_async API is registered and called. The callback provides the following details: socket ID of the accepted connection, address of remoter peer, and IP version of connection.

Returns

  • N/A


Definition at line 125 of file components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_types.h

sl_si91x_socket_data_transfer_complete_handler_t#

sl_si91x_socket_data_transfer_complete_handler_t )(int32_t socket, uint16_t length)

Callback function indicates data transfer status.

Parameters
N/Asocket

Socket ID.

N/Alength

Number of bytes transferred.

The callback indicates the data transfer completion status when either of the sl_si91x_send_async or sl_si91x_sendto_async API is registered and called. The callback provides the socket ID, and the number of bytes that are successfully transfer.

Returns

  • N/A


Definition at line 144 of file components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_types.h

sl_si91x_socket_select_callback_t#

sl_si91x_socket_select_callback_t )(fd_set *fd_read, fd_set *fd_write, fd_set *fd_except, int32_t status)

Callback function indicates asynchronous select request result.

Parameters
N/Afd_read

File descriptor pointer sets for read operations.

N/Afd_write

File descriptor pointer sets for write operations.

N/Afd_except

File descriptor pointer sets for exception condition.

N/Astatus

Select request status.

The callback indicates asynchronous response reaches the select request when the sl_si91x_select API is registered and called. The callback provides the following details: file descriptor sets for read, write, and exception conditions, and status of the selected request.

Returns

  • N/A


Definition at line 169 of file components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_types.h

sl_si91x_socket_remote_termination_callback_t#

sl_si91x_socket_remote_termination_callback_t )(int socket, uint16_t port, uint32_t bytes_sent)

Callback function indicates termination of the remote socket.

Parameters
N/Asocket

Socket ID.

N/Aport

Remote socket port number.

N/Abytes_sent

Number of bytes sent before termination.

The callback function notifies on the termination of the remote socket when the sl_si91x_set_remote_termination_callback API is registered and called. The callback provides the following details: socket ID, remote socket port number, and number of bytes sent before termination of the remote socket.

Returns

  • The callback does not returns value.


Definition at line 191 of file components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_types.h

Function Documentation#

sl_si91x_socket#

int sl_si91x_socket (int family, int type, int protocol)

Creates a new socket.

Parameters
[in]family

Specifies the communication domain for the socket. This selects the protocol family to be used. Accepts values from Socket Address Family. Currently, only AF_INET and AF_INET6 are supported.

[in]type

Specifies the type of the socket, which determines the semantics of communication. Accepts values from Socket Type. Currently, only SOCK_STREAM and SOCK_DGRAM are supported.

[in]protocol

Specifies a particular protocol to be used with the socket. Accepts values from Socket Protocol. Currently, only IPPROTO_TCP, IPPROTO_UDP, and IPPROTO_IP are supported.

The function creates a new socket and returns a file descriptor for the respective socket. The socket is used for communication within the specified protocol family, type, and protocol. The created socket is used for various network operations such as, connecting to a remote host, sending and receiving data, and so on.

Returns

  • Returns the socket ID or file descriptor for the newly created socket on success, or -1 on failure.


Definition at line 61 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_socket_async#

int sl_si91x_socket_async (int family, int type, int protocol, sl_si91x_socket_receive_data_callback_t callback)

Creates an asynchronous socket and registers the provided callback.

Parameters
[in]family

Specifies the communication domain for the socket. This selects the protocol family to be used. Accepts values from Socket Address Family. Currently, only AF_INET and AF_INET6 are supported.

[in]type

Specifies the type of the socket, which determines the semantics of communication. Accepts values from Socket Type. Currently, only SOCK_STREAM and SOCK_DGRAM are supported.

[in]protocol

Specifies a particular protocol to be used with the socket. Accepts values from Socket Protocol. Currently, only IPPROTO_TCP, IPPROTO_UDP, and IPPROTO_IP are supported.

[in]callback

A function pointer of type sl_si91x_socket_receive_data_callback_t. This function is called when the socket receives data.

This function creates a new asynchronous socket and registers a callback function that is called whenever data is received on the socket. The socket can be used for communication within the specified protocol family, type, and protocol.

Returns

  • Returns the socket ID or file descriptor for the newly created socket on success, or -1 on failure.


Definition at line 84 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_setsockopt#

int sl_si91x_setsockopt (int32_t socket, int level, int option_name, const void * option_value, socklen_t option_len)

Sets a specified socket option on the identified socket asynchronously.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]level

The option level. Accepts values from Socket Option Level.

[in]option_name

The option to be configured. Accepts values from SiWx91x Socket Option Name. Currently, following options are supported:

[in]option_value

The value of the parameter.

option_name

option_value

description

SL_SI91X_SO_RCVTIME

sl_si91x_time_value

Socket Receive timeout. sl_si91x_time_value structure is used to represent time in two parts: seconds and microseconds.

SL_SI91X_SO_MAXRETRY

uint16_t

Maximum number of TCP retries

SL_SI91X_SO_MSS

uint16_t

Maximum Segment Size (MSS) for the TCP connection

SL_SI91X_SO_TCP_KEEPALIVE

uint16_t

Set TCP keepalive in seconds

SL_SI91X_SO_HIGH_PERFORMANCE_SOCKET

BIT(7)

Set high performance socket

SL_SI91X_SO_SSL_ENABLE

SL_SI91X_ENABLE_TLS

Enable TLS/SSL

SL_SI91X_SO_SSL_V_1_0_ENABLE

SL_SI91X_TLS_V_1_0

Enable TLS v1.0

SL_SI91X_SO_SSL_V_1_1_ENABLE

SL_SI91X_TLS_V_1_1

Enable TLS v1.1

SL_SI91X_SO_SSL_V_1_2_ENABLE

SL_SI91X_TLS_V_1_2

Enable TLS v1.2

SL_SI91X_SO_SSL_V_1_3_ENABLE

SL_SI91X_TLS_V_1_3

Enable TLS v1.3

SL_SI91X_SO_SOCK_VAP_ID

uint8_t

Specifies the interface on which the socket will operate

SL_SI91X_SO_CERT_INDEX

uint8_t

Certificate index

SL_SI91X_SO_TLS_SNI

sl_si91x_socket_type_length_value_t

Server Name Indication (SNI)

SL_SI91X_SO_TLS_ALPN

sl_si91x_socket_type_length_value_t

Application-Layer Protocol Negotiation (ALPN)

SL_SI91X_SO_MAX_RETRANSMISSION_TIMEOUT_VALUE

uint8_t

Maximum retransmission timeout value for TCP

[in]option_len

The length of the parameter of type socklen_t.

This function sets a specified option for a given socket asynchronously. The options can be set at various levels and include parameters such as receive timeout, maximum retries, maximum segment size, TCP keepalive, SSL options, and so on.

Returns

  • Returns 0 on success, or -1 on failure.

Note

  • This function is used only for the SiWx91x socket API. The options set in this function will not be effective if called after sl_si91x_connect() or sl_si91x_listen() for TCP, or after sl_si91x_sendto(), sl_si91x_recvfrom(), or sl_si91x_connect() for UDP. The value of the option SL_SI91X_SO_MAX_RETRANSMISSION_TIMEOUT_VALUE should be a power of 2.


Definition at line 150 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_bind#

int sl_si91x_bind (int socket, const struct sockaddr * addr, socklen_t addr_len)

Assigns a local protocol address to a socket.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]addr

Pointer to a struct sockaddr contains the address to which the socket is bound. This address specifies the local IP address and port number.

[in]addr_len

The length of the socket address, in bytes, of type socklen_t.

The function binds a socket to a specific local address and port number. It is typically used on the server side to specify the port on which the server will listen for incoming connections.

Returns

  • Returns 0 on success, or -1 on failure.


Definition at line 173 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_listen#

int sl_si91x_listen (int socket, int max_number_of_clients)

Enables a socket to listen for remote connection requests in passive mode.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]max_number_of_clients

The maximum number of pending connections which the socket can queue.

The function configures a socket to listen for incoming connection requests. It is typically used on the server side after the socket has been bound to a local address using the sl_si91x_bind function. The socket enters passive mode, where it waits for remote clients to connect.

Returns

  • Returns 0 on success, or -1 on failure.


Definition at line 193 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_accept#

int sl_si91x_accept (int socket, const struct sockaddr * addr, socklen_t addr_len)

Accepts a connection request from a remote peer.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]addr

The address of type sockaddr to which datagrams are to be sent.

[in]addr_len

The length of the socket address of type socklen_t in bytes.

The function blocks until a client attempts to connect to the server socket. After receiving a connection request, it proceeds.

Returns

  • int


Definition at line 206 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_accept_async#

int sl_si91x_accept_async (int socket, sl_si91x_socket_accept_callback_t callback)

Accepts a connection request from the remote peer and registers a callback.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]callback

A function pointer of type sl_si91x_socket_accept_callback_t that is called when a new client is connected to the server.

The function sets up the server socket to listen for incoming connections, and immediately returns without blocking the main program's execution.

Returns

  • int


Definition at line 222 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_connect#

int sl_si91x_connect (int socket, const struct sockaddr * addr, socklen_t addr_len)

Initiates a connection to a remote socket specified by the addr parameter.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]addr

Address of type sockaddr to which datagrams are to be sent.

[in]addr_len

Length of the socket address of type socklen_t in bytes.

The function initiates a connection to a remote socket specified by the addr parameter. It is typically used on the client side to establish a connection to a server.

Returns

  • int


Definition at line 240 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_send#

int sl_si91x_send (int socket, const uint8_t * buffer, size_t buffer_length, int32_t flags)

Sends the data to the remote peer on the given socket.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]buffer

Pointer to the buffer containing data to send to the remote peer.

[in]buffer_length

Length of the buffer pointed to by the buffer parameter.

[in]flags

Controls the transmission of the data.

This should be used only when the socket is in a connected state.

Returns

  • int

Note

  • The flags parameter is not currently supported.

  • For TCP, the maximum buffer length should not exceed the MSS.

  • The following table lists the maximum buffer length which could be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

UDP

1472 bytes

TCP

1460 bytes

TLS

1370 bytes


Definition at line 268 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_send_async#

int sl_si91x_send_async (int socket, const uint8_t * buffer, size_t buffer_length, int32_t flags, sl_si91x_socket_data_transfer_complete_handler_t callback)

Transmits one or more messages to a socket asynchronously.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]buffer

Pointer to the buffer containing data to send to the remote peer

[in]buffer_length

Length of the buffer pointed to by the buffer parameter.

[in]flags

Controls the transmission of the data.

[in]callback

A function pointer of type sl_si91x_socket_data_transfer_complete_handler_t that is called after complete data transfer.

This should be used only when the socket is in a connected state.

Returns

  • int

Note

  • The flags parameter is not currently supported.

  • For TCP, the maximum buffer length should not exceed the MSS.

  • The following table lists the maximum buffer length which could be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

UDP

1472 bytes

TCP

1460 bytes

TLS

1370 bytes


Definition at line 298 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_sendto#

int sl_si91x_sendto (int socket, const uint8_t * buffer, size_t buffer_length, int32_t flags, const struct sockaddr * addr, socklen_t addr_len)

Transmits one or more messages to another socket.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]buffer

Pointer to data buffer contains data to send to remote peer.

[in]buffer_length

Length of the buffer pointed to by the buffer parameter.

[in]flags

Controls the transmission of the data.

[in]addr

Address of type sockaddr to which datagrams are to be sent.

[in]addr_len

Length of the socket address of type socklen_t in bytes.

The function is called from an unconnected socket, typically like a UDP socket.

Returns

  • int

Note

  • The flags parameter is not currently supported.

  • For TCP, the maximum buffer length should not exceed the MSS.

  • The following table lists the maximum buffer length which could be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

UDP

1472 bytes

TCP

1460 bytes

TLS

1370 bytes


Definition at line 334 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_sendto_async#

int sl_si91x_sendto_async (int socket, const uint8_t * buffer, size_t buffer_length, int32_t flags, const struct sockaddr * to_addr, socklen_t to_addr_len, sl_si91x_socket_data_transfer_complete_handler_t callback)

Transmits one or more messages to another socket asynchronously, and receives acknowledgement through the registered callback.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]buffer

Pointer to data buffer contains data to send to remote peer.

[in]buffer_length

Length of the buffer pointed to by the buffer parameter.

[in]flags

Controls the transmission of the data.

[in]to_addr

Address of type sockaddr to which datagrams are to be sent.

[in]to_addr_len

Length of the socket address of type socklen_t in bytes.

[in]callback

A function pointer of type sl_si91x_socket_data_transfer_complete_handler_t that is called after complete data transfer.

The function can also be called from an unconnected socket, typically like a UDP socket.

Returns

  • int

Note

  • The flags parameter is not currently supported.

  • For TCP, the maximum buffer length should not exceed the MSS.

  • The following table lists the maximum buffer length which could be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

UDP

1472 bytes

TCP

1460 bytes

TLS

1370 bytes


Definition at line 373 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_send_large_data#

int sl_si91x_send_large_data (int socket, const uint8_t * buffer, size_t buffer_length, int32_t flags)

Sends data that is larger than the Maximum Segment Size (MSS).

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[in]buffer

Pointer to the data buffer contains the data to be sent to the remote peer.

[in]buffer_length

The length of the buffer pointed to by the buffer parameter.

[in]flags

Controls the transmission of the data. Note that the flags parameter is not currently supported.

This function sends data that exceeds the MSS size to a remote peer. It handles the segmentation of the data into smaller chunks that fit within the MSS limit. This API can even be used when the buffer length is less than the MSS.

Returns

  • Returns the number of bytes sent on success, or -1 on failure.


Definition at line 404 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_recv#

int sl_si91x_recv (int socket, uint8_t * buffer, size_t bufferLength, int32_t flags)

Receives data from a connected socket.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[out]buffer

Pointer to the buffer holds the data received from the remote peer.

[in]bufferLength

The length of the buffer pointed to by the buffer parameter.

[in]flags

Controls the reception of the data. Note that the flags parameter are not currently supported.

This function receives data from a connected socket and stores it in the specified buffer. It is typically used on the client or server side to read incoming data from a remote peer.

Returns

  • Returns the number of bytes received on success, or -1 on failure.


Definition at line 428 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_recvfrom#

int sl_si91x_recvfrom (int socket, uint8_t * buffer, size_t buffersize, int32_t flags, struct sockaddr * fromAddr, socklen_t * fromAddrLen)

Receives data from an unconnected socket, typically a UDP socket.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket.

[out]buffer

Pointer to the buffer that will hold the data received from the remote peer.

[in]buffersize

The size of the buffer pointed to by the buffer parameter.

[in]flags

Controls the reception of the data. Note that the flags parameter is not currently supported.

[out]fromAddr

Pointer to a sockaddr that will hold the address of the remote peer from which the current packet was received.

[inout]fromAddrLen

Pointer to a socklen_t that contains the length of the remote peer address (fromAddr). On return, it will contain the actual length of the address.

This function receives data from an unconnected socket and stores it in the specified buffer. It is typically used to receive data from a remote peer without establishing a connection.

Returns

  • Returns the number of bytes received on success, or -1 on failure.


Definition at line 459 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_shutdown#

int sl_si91x_shutdown (int socket, int how)

Disables send or receive operations on a socket.

Parameters
[in]socket

The socket ID or file descriptor for the specified socket that is to be closed.

[in]how

Determines the scope of the shutdown operation:

  • 0: Close the specified socket.

  • 1: Close all sockets open on the specified socket's source port number.

This function disables further send or receive operations on a specified socket. It can either close a specific socket or all sockets associated with a given port number.

Returns

  • Returns 0 on success, or -1 on failure.

Note

  • If the socket is a server socket, the how parameter is ignored, and the socket is always closed based on the port number.


Definition at line 487 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_select#

int sl_si91x_select (int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, const struct timeval * timeout, sl_si91x_socket_select_callback_t callback)

The sl_si91x_select() function is used to monitor multiple file descriptors for readiness to perform I/O operations.

Parameters
[in]nfds

The first nfds descriptors are checked in each set; that is, the descriptors from 0 through nfds-1.

[inout]readfds

A pointer to a fd_set object that specifies the descriptors to check for files that are ready for reading.

[inout]writefds

A pointer to a fd_set object that specifies the descriptors to check for files that are ready for writing.

[inout]exceptfds

A pointer to a fd_set object that will be watched for exceptions.

[in]timeout

If timeout is provided, the device shall wait for timeout duration for the file descriptors to become ready. If timeout is NULL, the device shall wait indefinitely for the file descriptors to become ready.

[in]callback

A function pointer of type sl_si91x_socket_select_callback_t that will be called when an asynchronous response is received for a select request.

The file descriptors in the sets are monitored to see if they are ready for reading, ready for writing, or have an error condition pending.

sl_si91x_select() allows a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready" for some class of I/O operation (e.g., input possible). A file descriptor is considered ready if it is possible to perform a corresponding I/O operation without blocking.

Returns

  • If callback is provided, the function will immediately return zero for success, and -1 for failure. If callback is NULL, returns:

    • total number of file descriptors set on success.

    • 0 when no file descriptors are ready within the specified timeout.

    • -1 on failure.

Note

  • The select function modifies the sets passed to it, so if the function is to be called again, the sets must be reinitialized. The exceptfds parameter is not currently supported.


Definition at line 527 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_set_remote_termination_callback#

void sl_si91x_set_remote_termination_callback (sl_si91x_socket_remote_termination_callback_t callback)

Registers a callback for remote socket termination events.

Parameters
[in]callback

A valid function pointer of type sl_si91x_socket_remote_termination_callback_t that is called when the remote socket is terminated.

This function registers a callback function is called when a remote socket is terminated. The callback function should be of type sl_si91x_socket_remote_termination_callback_t.


Definition at line 544 of file components/device/silabs/si91x/wireless/asynchronous_socket/inc/sl_si91x_socket.h

sl_si91x_get_socket_info#

sl_status_t sl_si91x_get_socket_info (sl_si91x_socket_info_response_t * socket_info_response)

Retrieve information about currently opened sockets from the network stack.

Parameters
[out]socket_info_response

Pointer to a sl_si91x_socket_info_response_t structure that will hold the response from the firmware.

Returns

  • sl_status_t

Note

  • The socket IDs in the response are specific to the firmware and should not be used as file descriptors in socket APIs.


Definition at line 93 of file components/service/bsd_socket/si91x_socket/sl_si91x_socket_support.h

sl_si91x_get_socket_mss#

int16_t sl_si91x_get_socket_mss (int32_t socketIndex)

Retrieves the Maximum Segment Size (MSS) for a specific socket.

Parameters
[in]socketIndex

The index of the socket for which the MSS is to be retrieved. This is an integer value that uniquely identifies the socket.

The MSS is the largest amount of data, specified in bytes, that a computer or communications device can handle in a single, unfragmented piece. Returns

  • Returns an int16_t value representing the MSS of the specified socket in bytes.


Definition at line 47 of file components/device/silabs/si91x/wireless/socket/inc/sl_bsd_utility.h