BSD Sockets#

Functions#

int32_t
rsi_web_socket_create(int8_t flags, uint8_t *server_ip_addr, uint16_t server_port, uint16_t device_port, uint8_t *webs_resource_name, uint8_t *webs_host_name, int32_t *socket_id, void(*web_socket_data_receive_notify_callback)(uint32_t sock_no, uint8_t *buffer, uint32_t length))

Create a web socket client. This is a blocking API.

int32_t
rsi_web_socket_send_async(int32_t sockID, uint8_t opcode, int8_t *msg, int32_t msg_length)

Send data from the web socket client. This is a non-blocking API.

int32_t
rsi_web_socket_close(int32_t sockID)

Close the web socket client. This is a non-blocking API.

int
rsi_fd_isset(uint32_t fd, struct rsi_fd_set_s *fds_p)

Check for the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.

void
rsi_set_fd(uint32_t fd, struct rsi_fd_set_s *fds_p)

Set the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.

void
rsi_fd_clr(uint32_t fd, struct rsi_fd_set_s *fds_p)

Clear the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.

int32_t
rsi_socket_async(int32_t protocolFamily, int32_t type, int32_t protocol, void(*callback)(uint32_t sock_no, uint8_t *buffer, uint32_t length))

Create a socket and register a callback that will be used by the driver to forward the received packets asynchronously to the application (on packet reception) without waiting for rsi_recv() API call. This is a non-blocking API.

int32_t
rsi_socket(int32_t protocolFamily, int32_t type, int32_t protocol)

Create and return a socket instance. This is a non-blocking API.

int32_t
rsi_bind(int32_t sockID, struct rsi_sockaddr *localAddress, int32_t addressLength)

Assign an address to a socket. This is a non-blocking API for TCP and a blocking API for UDP.

int32_t
rsi_connect(int32_t sockID, struct rsi_sockaddr *remoteAddress, int32_t addressLength)

Connect the socket to the specified remote address. This is a non-blocking API, if socket_connect_response handler() is registered through rsi_wlan_register_callbacks(), otherwise it is a blocking API.

int32_t
rsi_listen(int32_t sockID, int32_t backlog)

Enable socket to listen for a remote connection request in passive mode. This is a blocking API.

int32_t
rsi_accept_non_rom(int32_t sockID, struct rsi_sockaddr *ClientAddress, int32_t *addressLength)

Accept the connection request from the remote peer. This API extracts the connection request from the queue of pending connections on listening socket and accepts it.

int32_t
rsi_accept(int32_t sockID, struct rsi_sockaddr *ClientAddress, int32_t *addressLength)

Accept the connection request from the remote peer. This API extracts the connection request from the queue of pending connections on listening socket and accepts it. This is a blocking API.

int32_t
rsi_recv_large_data_sync(int32_t sockID, int8_t *buffer, int32_t requested_length, int32_t flags, struct rsi_sockaddr *fromAddr, int32_t *fromAddrLen)

Receive large data on a given socket synchronously.

int32_t
rsi_recvfrom(int32_t sockID, int8_t *buffer, int32_t buffersize, int32_t flags, struct rsi_sockaddr *fromAddr, int32_t *fromAddrLen)

Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.

int32_t
rsi_recv(int32_t sockID, void *rcvBuffer, int32_t bufferLength, int32_t flags)

Retrieve the data from the remote peer on a specified socket. This is a blocking API.

int32_t
rsi_sendto(int32_t sockID, int8_t *msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr *destAddr, int32_t destAddrLen)

Send data to the specified remote IP Address on the given socket. This is non-blocking API.

int32_t
rsi_sendto_async(int32_t sockID, int8_t *msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr *destAddr, int32_t destAddrLen, void(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send the data to the specified remote IP Address on the given socket and receive the acknowledgement through the registered call back. This is non-blocking API.

int32_t
rsi_send(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags)

Sends the data to the remote peer on the given socket. This is a non-blocking API.

void

Reset all the socket related information.

int32_t
rsi_send_large_data_sync(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags)

Send large data on a given socket synchronously.

void
rsi_chunk_data_tx_done_cb(int32_t sockID, const uint16_t length)

Send one chunk of data at a time.

int32_t
rsi_send_large_data_async(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags, void(*rsi_sock_data_tx_done_cb)(int32_t sockID, int16_t status, uint16_t total_data_sent))

Send large data on a given socket. This is a blocking API.

uint32_t
rsi_find_socket_data_pending(uint32_t event_map)

Find on which socket the data is pending, according to the event that is set from the event map.

void

Retrieve the packet from TX data pending queue and forward to the module.

int32_t
rsi_send_async(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags, void(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data on a given socket asynchronously.

int32_t
rsi_vap_shutdown(uint8_t vapID)

Closes all the sockets associate with a vap_Id. This is a blocking API.

int32_t
rsi_shutdown(int32_t sockID, int32_t how)

Closes the socket specified in a socket descriptor. This is a blocking API.

int32_t

Get the application socket descriptor from module socket descriptor.

void
rsi_clear_sockets(int32_t sockID)

Clear socket information.

int
rsi_fill_tls_extension(int32_t sockID, int extension_type, const void *option_value, rsi_socklen_t extension_len)

Configure TLS extensions.

int
rsi_setsockopt(int32_t sockID, int level, int option_name, const void *option_value, rsi_socklen_t option_len)

Set the socket options. This is a non-blocking API.

int
rsi_getsockopt(int32_t sockID, int level, int option_name, const void *option_value, rsi_socklen_t option_len)

Get the socket options. This is a non-blocking API.

int32_t
rsi_select(int32_t nfds, rsi_fd_set *readfds, rsi_fd_set *writefds, rsi_fd_set *exceptfds, struct rsi_timeval *timeout, void(*callback)(rsi_fd_set *fd_read, rsi_fd_set *fd_write, rsi_fd_set *fd_except, int32_t status))

Monitor multiple socket (file descriptors), waiting until one or more of the sockets become ready to perform receive or send operation. If callback is NULL or not provided, it is a blocking API. Otherwise, it is a non-blocking API.

uint8_t
calculate_buffers_required(uint8_t type, uint16_t length)

Calculate the buffers required.

int32_t
rsi_accept_async(int32_t sockID, void(*callback)(int32_t sock_id, int16_t dest_port, uint8_t *ip_addr, int16_t ip_version))

Accept the connection request from the remote peer and register a callback that will be used by the driver to forward the received connection request asynchronously to the application. This is a non-blocking API.

int32_t

Get the application socket descriptor from source port.

int32_t
rsi_get_socket_id(uint32_t src_port, uint32_t dst_port)

Get the socket ID from port number.

int32_t
rsi_get_primary_socket_id(uint8_t *port_num)

Get the primary socket ID from port number.

int32_t
rsi_certificate_valid(uint16_t valid, uint16_t socket_id)

Validate the server certificate received from the module. This is a non-blocking API.

int32_t
rsi_socket_create_async(int32_t sockID, int32_t type, int32_t backlog)

Send socket create request to the module and receive the response asynchronously. This is a non-blocking API if socket_connect_response_handler is registered. Otherwise it is a blocking API.

int32_t
rsi_get_socket_descriptor(uint8_t *src_port, uint8_t *dst_port, uint8_t *ip_addr, uint16_t ip_version, uint16_t sockid)

Get the socket descriptor based on source port number, destination port number, destination IP address, and the IP version. This is a non-blocking API.

int32_t
rsi_socket_async_non_rom(int32_t protocolFamily, int32_t type, int32_t protocol, void(*callback)(uint32_t sock_no, uint8_t *buffer, uint32_t length))

Create a socket and register a callback that will be used by the driver to forward the received packets asynchronously to the application (on packet reception) without waiting for recv API (Add proper API here). This is a non-blocking API.

int32_t
rsi_socket_connect(int32_t sockID, struct rsi_sockaddr *remoteAddress, int32_t addressLength)

Connect the socket to specific remote address. This is a non-blocking API, if socket_connect_response_handler() is registered through rsi_wlan_register_callbacks(). Otherwise it is a blocking API.

int32_t
rsi_socket_recvfrom(int32_t sockID, int8_t *buffer, int32_t buffersize, int32_t flags, struct rsi_sockaddr *fromAddr, int32_t *fromAddrLen)

Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.

int32_t
rsi_socket_listen(int32_t sockID, int32_t backlog)

Enable socket to listen for remote connection request in passive mode. This is a blocking API.

int32_t

Close all the sockets associated with a VAP Id. This is a blocking API.

int32_t
rsi_socket_shutdown(int32_t sockID, int32_t how)

Close the socket specified in a socket descriptor. This is a blocking API.

int32_t
rsi_socket_bind(int32_t sockID, struct rsi_sockaddr *localAddress, int32_t addressLength)

Assign address to the socket. This is a non-blocking API for TCP and a blocking API for UDP.

rsi_error_t
rsi_wait_on_socket_semaphore(rsi_semaphore_handle_t *semaphore, uint32_t timeout_ms)

Wait for network semaphore.

int32_t

Get the application socket descriptor from module’s socket descriptor. This is a non-blocking API.

int32_t

Get WLAN socket status. This is a non-blocking API.

void
rsi_wlan_socket_set_status(int32_t status, int32_t sockID)

Set WLAN status. This is a non-blocking API.

int32_t
rsi_select_get_status(int32_t selectid)

Get the status of the socket specified in the select ID.

void
rsi_select_set_status(int32_t status, int32_t selectid)

Set the status of the socket specified in the select ID.

int32_t
rsi_send_async_non_rom(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags, void(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data on a given socket asynchronously.

int32_t
rsi_sendto_async_non_rom(int32_t sockID, int8_t *msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr *destAddr, int32_t destAddrLen, void(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data to specific remote peer on a given socket.

void

Clear socket information.

int32_t
ROM_WL_rsi_get_application_socket_descriptor(global_cb_t *global_cb_p, int32_t sock_id)

Get the application socket descriptor from module’s socket descriptor. This is a non-blocking API.

int32_t
ROM_WL_rsi_get_primary_socket_id(global_cb_t *global_cb_p, uint16_t port_number)

Get socket descriptor from port_number. This is a non-blocking API.

uint8_t
ROM_WL_calculate_buffers_required(global_cb_t *global_cb_p, uint8_t type, uint16_t length)

Calculate number of buffers required for the data packet. This is a non-blocking API.

uint16_t
ROM_WL_calculate_length_to_send(global_cb_t *global_cb_p, uint8_t type, uint8_t buffers)

Calculate the length available in the buffers for the message. This is a non-blocking API.

int32_t

Set the socket configuration parameters. The configurations can be done using the Socket configuration in the rsi_wlan_config.h file. Using this API is highly recommended. Based on the socket configuration, module will use available buffers effectively. This is a blocking API.

Function Documentation#

rsi_web_socket_create#

int32_t rsi_web_socket_create (int8_t flags, uint8_t * server_ip_addr, uint16_t server_port, uint16_t device_port, uint8_t * webs_resource_name, uint8_t * webs_host_name, int32_t * socket_id, void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length) web_socket_data_receive_notify_callback, sock_no, buffer, length)

Create a web socket client. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int8_t[in]flags

- Select IP version and security BIT(0): RSI_IPV6 - Set this bit to enable IPv6, by default it is configured to IPv4 BIT(1): RSI_SSL_ENABLE - Set this bit to enable SSL feature

uint8_t *[in]server_ip_addr

- Web server IP address

uint16_t[in]server_port

- Web server socket port

uint16_t[in]device_port

- Local port

uint8_t *[in]webs_resource_name

- Web resource name

uint8_t *[in]webs_host_name

- Web host name

int32_t *[in]socket_id

- Socket ID

void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length)[in]web_socket_data_receive_notify_callback

- Callback when data packet is received on the created socket

[out]sock_no

- Application socket ID

[out]buffer

- Buffer pointer

[out]length

- Length of data

Returns

  • 0 - Success

  • Negative Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffc)

Note


rsi_web_socket_send_async#

int32_t rsi_web_socket_send_async (int32_t sockID, uint8_t opcode, int8_t * msg, int32_t msg_length)

Send data from the web socket client. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Application socket ID

uint8_t[in]opcode

- Type of the packet to be included in web socket header

int8_t *[in]msg

- Data

int32_t[in]msg_length

- Data length

Returns

  • 0 - Success

  • Negative Value - Failure

Note


rsi_web_socket_close#

int32_t rsi_web_socket_close (int32_t sockID)

Close the web socket client. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket ID of particular socket

Returns

  • 0 - Success

  • Negative Value - Failure

Note


rsi_fd_isset#

int rsi_fd_isset (uint32_t fd, struct rsi_fd_set_s * fds_p)

Check for the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]fd

- Socket ID

struct rsi_fd_set_s *[in]fds_p

- Pointer to the rsi_fd_set_s structure

Returns

  • Positive Value - Success

  • 0 - Failure


rsi_set_fd#

void rsi_set_fd (uint32_t fd, struct rsi_fd_set_s * fds_p)

Set the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]fd

- Socket id

struct rsi_fd_set_s *[in]fds_p

- Pointer to the rsi_fd_set_structure

Returns

  • Void


rsi_fd_clr#

void rsi_fd_clr (uint32_t fd, struct rsi_fd_set_s * fds_p)

Clear the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]fd

- Socket ID

struct rsi_fd_set_s *[in]fds_p

- Pointer to the rsi_fd_set_s structure

Returns

  • Void


rsi_socket_async#

int32_t rsi_socket_async (int32_t protocolFamily, int32_t type, int32_t protocol, void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length) callback, sock_no, buffer, length)

Create a socket and register a callback that will be used by the driver to forward the received packets asynchronously to the application (on packet reception) without waiting for rsi_recv() API call. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]protocolFamily

- Protocol family to select IPv4 or IPv6. AF_INET (2) : Select IPv4 AF_INET6 (3) : Select IPv6

int32_t[in]type

- Select socket type UDP or TCP. SOCK_STREAM (1) : Select TCP SOCK_DGRM (2) : Select UDP

int32_t[in]protocol

- 0: Non SSL sockets 1: SSL sockets BIT(5) - Must be enabled to select the certificate index 0<<12 for index 0, 1<<12 for index 1 Note: Certificates must be loaded in to RAM to select the certificate index feature.

void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length)[in]callback

- Callback function to read data asynchronously from socket

[out]sock_no

- Application socket number

[out]buffer

- Pointer to buffer that holds data

[out]length

- Length of the buffer

Returns

  • 0 - Success

  • Non-Zero Value - Failure (Possible Error Codes - 0xFFF8, 0xFF80, 0xFF6D, 0xFF85, 0xBB33, 0xBB22)

Note


rsi_socket#

int32_t rsi_socket (int32_t protocolFamily, int32_t type, int32_t protocol)

Create and return a socket instance. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]protocolFamily

- Protocol family to select IPv4 or IPv6. AF_INET (2): Select IPv4 AF_INET6 (3): Select IPv6

int32_t[in]type

- Select socket type UDP or TCP. SOCK_STREAM (1): Select TCP TCP SOCK_DGRM (2): Select UDP

int32_t[in]protocol

- 0: Non SSL sockets 1: SSL sockets BIT(5) - Must be enabled to select the certificate index 0<<12 for index 0, 1<<12 for index 1 Note: Certificates must be loaded in to RAM to select the certificate index feature.

Returns

  • SOCK_ID - Socket ID of the created socket

  • Negative value - Failure (Possible Error Codes - 0xfffffffd)

Note


rsi_bind#

int32_t rsi_bind (int32_t sockID, struct rsi_sockaddr * localAddress, int32_t addressLength)

Assign an address to a socket. This is a non-blocking API for TCP and a blocking API for UDP.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

struct rsi_sockaddr *[in]localAddress

- Address assigned to the socket. The format is compatible with BSD socket

int32_t[in]addressLength

- Length of the address measured in bytes

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note

  • Precondition - rsi_socket() API needs to be called before this API.


References SL_PRINTF , and rsi_socket_bind

rsi_connect#

int32_t rsi_connect (int32_t sockID, struct rsi_sockaddr * remoteAddress, int32_t addressLength)

Connect the socket to the specified remote address. This is a non-blocking API, if socket_connect_response handler() is registered through rsi_wlan_register_callbacks(), otherwise it is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

struct rsi_sockaddr *[in]remoteAddress

- Remote peer address. The format is compatible with BSD socket.

int32_t[in]addressLength

- Length of the address in bytes

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Precondition - rsi_socket()/ rsi_bind() API needs to be called before this API.

  • For asynchronous behaviour, user need to register RSI_WLAN_SOCKET_CONNECT_NOTIFY_CB callback ID.


References SL_PRINTF , and rsi_socket_connect

rsi_listen#

int32_t rsi_listen (int32_t sockID, int32_t backlog)

Enable socket to listen for a remote connection request in passive mode. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int32_t[in]backlog

- Maximum length to which the queue of pending connections can be held. This argument is used when multiple client connections over the same server socket are required. If backlog parameter is issued, then rsi_accept or rsi_accept_async can accept those many client connections over the same server socket

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note

  • Precondition - rsi_bind() API needs to be called before this API.

  • When using multiple client/server sockets, the following macros have to be updated in the wlan_config.h file, in TCP_IP_FEATURE_BIT_MAP - If TCP_IP_TOTAL_SOCKETS_x flag is used, then firmware allocates memory for x sockets. If TCP_IP_TOTAL_SOCKETS_x flag is not passed, then a default value of 10 sockets is used.

  • When using multiple client/server sockets, the following macros have to be updated in the rsi_user.h file, RSI_NUMBER_OF_LTCP_SOCKETS -> Number of server sockets and RSI_NUMBER_OF_SOCKETS -> Number of client sockets + Number of server sockets.

  • If multiple server sockets are created then the memory allocated for client sockets is to be shared across the multiple server sockets. If RSI_NUMBER_OF_LTCP_SOCKETS is 0 and RSI_NUMBER_OF_SOCKETS is x, y is server sockets and x-y client sockets can be created


References SL_PRINTF , and rsi_socket_listen

rsi_accept_non_rom#

int32_t rsi_accept_non_rom (int32_t sockID, struct rsi_sockaddr * ClientAddress, int32_t * addressLength)

Accept the connection request from the remote peer. This API extracts the connection request from the queue of pending connections on listening socket and accepts it.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

struct rsi_sockaddr *[in]ClientAddress

- Remote peer address

int32_t *[in]addressLength

- Length of the address measured in bytes

Returns

  • > 0 - Client socket ID

  • <= 0 - Failure

Note


rsi_accept#

int32_t rsi_accept (int32_t sockID, struct rsi_sockaddr * ClientAddress, int32_t * addressLength)

Accept the connection request from the remote peer. This API extracts the connection request from the queue of pending connections on listening socket and accepts it. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor

struct rsi_sockaddr *[in]ClientAddress

- Remote peer address

int32_t *[in]addressLength

- Length of the address measured in bytes

Returns

  • > 0 - Client socket ID

  • <= 0 - Failure

Note

  • Precondition - rsi_listen() API needs to be called before this API.


References SL_PRINTF , and rsi_accept_non_rom

rsi_recv_large_data_sync#

int32_t rsi_recv_large_data_sync (int32_t sockID, int8_t * buffer, int32_t requested_length, int32_t flags, struct rsi_sockaddr * fromAddr, int32_t * fromAddrLen)

Receive large data on a given socket synchronously.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor

int8_t *[in]buffer

- Pointer to buffer to hold receive data

int32_t[in]requested_length

- Requested buffer length

int32_t[in]flags

- Reserved

struct rsi_sockaddr *[in]fromAddr

- Address of remote peer, from where current packet was received

int32_t *[in]fromAddrLen

- Pointer that contains remote peer address (fromAddr) length

Returns

  • Number of bytes received successfully – Success

  • Negative value – Failure

  • 0 – Socket close error


Referenced by rsi_recvfrom , and rsi_recv

rsi_recvfrom#

int32_t rsi_recvfrom (int32_t sockID, int8_t * buffer, int32_t buffersize, int32_t flags, struct rsi_sockaddr * fromAddr, int32_t * fromAddrLen)

Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor

int8_t *[in]buffer

- Pointer to buffer to hold receive data

int32_t[in]buffersize

- Size of the buffer supplied

int32_t[in]flags

- Reserved

struct rsi_sockaddr *[in]fromAddr

- Address of remote peer, from where current packet was received

int32_t *[in]fromAddrLen

- Pointer that contains remote peer address (fromAddr) length

Returns

  • Number of bytes received successfully – Success

  • Negative value – Failure

  • 0 – Socket close error

Note


rsi_recv#

int32_t rsi_recv (int32_t sockID, void * rcvBuffer, int32_t bufferLength, int32_t flags)

Retrieve the data from the remote peer on a specified socket. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

void *[in]rcvBuffer

- Pointer to the buffer to hold the data received from the remote peer

int32_t[in]bufferLength

- Length of the buffer

int32_t[in]flags

- Reserved

Returns

  • Number of bytes received successfully – Success

  • Negative value – Failure

  • 0 – Socket close error

Note

  • Precondition (TCP client) - rsi_connect() API needs to be called before this API.

  • Precondition (TCP server) - rsi_listen() and rsi_accept() API needs to be called before this API.

  • Precondition (UDP server) - rsi_bind() API needs to be called before this API.

  • Precondition (UDP client) - rsi_socket() or rsi_bind() API needs to be called before this API


rsi_sendto#

int32_t rsi_sendto (int32_t sockID, int8_t * msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr * destAddr, int32_t destAddrLen)

Send data to the specified remote IP Address on the given socket. This is non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int8_t *[in]msg

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

int32_t[in]msgLength

- Length of the buffer

int32_t[in]flags

- Reserved

struct rsi_sockaddr *[in]destAddr

- Address of the remote peer to send data

int32_t[in]destAddrLen

- Length of the address in bytes

Returns

  • Number of bytes received successfully – Success

  • Negative value – Failure

  • 0 – Socket close error

Note

  • Precondition (TCP client) - rsi_connect() API needs to be called before this API.

  • Precondition (TCP server) - rsi_listen() and rsi_accept() API needs to be called before this API.

  • Precondition (UDP server) - rsi_bind() API needs to be called before this API.

  • Precondition (UDP client) - rsi_socket() or rsi_bind() API needs to be called before this API

  • The following table lists the maximum individual chunk of data that can be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

TCP/LTCP socket

1460

LUDP socket

1472

Web socket

1450

TCP-SSL/LTCP-SSL

1370

Web socket over SSL

1362


rsi_sendto_async#

int32_t rsi_sendto_async (int32_t sockID, int8_t * msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr * destAddr, int32_t destAddrLen, void(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, length)

Send the data to the specified remote IP Address on the given socket and receive the acknowledgement through the registered call back. This is non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int8_t *[in]msg

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

int32_t[in]msgLength

- Length of data to send

int32_t[in]flags

- Reserved

struct rsi_sockaddr *[in]destAddr

- Address of the remote peer to send data

int32_t[in]destAddrLen

- Length of the address in bytes

void(*)(int32_t sockID, uint16_t length)[in]data_transfer_complete_handler

- Pointer to callback function called after complete data transfer

[out]length

- Number of bytes transfered

Returns

  • Number of bytes received successfully – Success

  • Negative value – Failure

  • 0 – Socket close error

Note

  • The following table lists the maximum individual chunk of data that can be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

TCP/LTCP socket

1460

LUDP socket

1472

Web socket

1450

TCP-SSL/LTCP-SSL

1370

Web socket over SSL

1362

Note

  • The data_transfer_complete_handler callback handler is supported only for TCP data transfer. This handler is supported only when RSI_WLAN_RSP_TCP_ACK_INDICATION feature is enabled in socket_feature_bitmap.


rsi_send#

int32_t rsi_send (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags)

Sends the data to the remote peer on the given socket. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

const int8_t *[in]msg

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

int32_t[in]msgLength

- Length of the buffer

int32_t[in]flags

- Reserved

Returns

  • Number of bytes received successfully – Success

  • Negative value – Failure

  • 0 – Socket close error

Note

  • Precondition - rsi_connect()/ rsi_accept() API needs to be called before this API.

  • The following table lists the maximum individual chunk of data that can be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

TCP/LTCP socket

1460

LUDP socket

1472

Web socket

1450

TCP-SSL/LTCP-SSL

1370

Web socket over SSL

1362


rsi_reset_per_socket_info#

void rsi_reset_per_socket_info (int32_t sockID)

Reset all the socket related information.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

Returns

  • Void


rsi_send_large_data_sync#

int32_t rsi_send_large_data_sync (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags)

Send large data on a given socket synchronously.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

const int8_t *[in]msg

- Pointer to data that needs to be sent to remote peer

int32_t[in]msgLength

- Length of data to send

int32_t[in]flags

- Reserved

Returns

  • 0 - Success

  • Non-Zero Value - Failure


rsi_chunk_data_tx_done_cb#

void rsi_chunk_data_tx_done_cb (int32_t sockID, const uint16_t length)

Send one chunk of data at a time.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

const uint16_t[in]length

- Length of data to send

Returns

  • Void


rsi_send_large_data_async#

int32_t rsi_send_large_data_async (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags, void(*)(int32_t sockID, int16_t status, uint16_t total_data_sent) rsi_sock_data_tx_done_cb, sockID, status, total_data_sent)

Send large data on a given socket. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

const int8_t *[in]msg

- Pointer to data that needs to be sent to remote peer

int32_t[in]msgLength

- Length of data to send

int32_t[in]flags

- Reserved

void(*)(int32_t sockID, int16_t status, uint16_t total_data_sent)[in]rsi_sock_data_tx_done_cb

- Pointer to the callback function that will be called after one chunk of data transfer completion

[out]sockID

- Application socket ID

[out]status

- Status of the data transfer

[out]total_data_sent

- Total length of data sent

Returns

  • 0 - Success

  • Non-Zero Value - Failure


rsi_find_socket_data_pending#

uint32_t rsi_find_socket_data_pending (uint32_t event_map)

Find on which socket the data is pending, according to the event that is set from the event map.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]event_map

- Event map

Returns

  • Socket ID from the event map


rsi_socket_event_handler#

void rsi_socket_event_handler (void )

Retrieve the packet from TX data pending queue and forward to the module.

Parameters
TypeDirectionArgument NameDescription
void[in]

Returns

  • Void


rsi_send_async#

int32_t rsi_send_async (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags, void(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)

Send data on a given socket asynchronously.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

const int8_t *[in]msg

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

int32_t[in]msgLength

- Length of the buffer

int32_t[in]flags

- Reserved

void(*)(int32_t sockID, uint16_t length)[in]data_transfer_complete_handler

- Pointer to callback function called after complete data transfer

[out]sockID

- Socket Descriptor ID

[out]length

- Number of bytes transfered

Returns

  • Number of bytes received successfully – Success

  • Negative value – Failure

  • 0 – Socket close error

Note

  • Precondition - rsi_socket()/ rsi_socket_async() API needs to be called before this API.

  • The following table lists the maximum individual chunk of data that can be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

TCP/LTCP socket

1460

LUDP socket

1472

Web socket

1450

TCP-SSL/LTCP-SSL

1370

Web socket over SSL

1362

Note

  • The data_transfer_complete_handler callback handler is supported only for TCP data transfer. This handler is supported only when RSI_WLAN_RSP_TCP_ACK_INDICATION feature is enabled in socket_feature_bitmap.


rsi_vap_shutdown#

int32_t rsi_vap_shutdown (uint8_t vapID)

Closes all the sockets associate with a vap_Id. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]vapID

- Virtual access point ID

Returns

  • 0 - Success Negative Value - Failure


rsi_shutdown#

int32_t rsi_shutdown (int32_t sockID, int32_t how)

Closes the socket specified in a socket descriptor. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int32_t[in]how

- 0: Close the specified socket 1: Close all the sockets open on a specified socket's source port number

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note


rsi_get_application_socket_descriptor#

int32_t rsi_get_application_socket_descriptor (int32_t sock_id)

Get the application socket descriptor from module socket descriptor.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sock_id

- Module's socket descriptor ID

Returns

  • Positive Value - Success (Application socket descriptor)

  • Negative Value - Failure (If module’s socket descriptor is not found)


rsi_clear_sockets#

void rsi_clear_sockets (int32_t sockID)

Clear socket information.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

Returns

  • Void


rsi_fill_tls_extension#

int rsi_fill_tls_extension (int32_t sockID, int extension_type, const void * option_value, rsi_socklen_t extension_len)

Configure TLS extensions.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int[in]extension_type

- Type of TLS extension

const void *[in]option_value

- TLS extension data

rsi_socklen_t[in]extension_len

- TLS extension data length

Returns

  • 0 - Success

  • Non-Zero Value - Failure


rsi_setsockopt#

int rsi_setsockopt (int32_t sockID, int level, int option_name, const void * option_value, rsi_socklen_t option_len)

Set the socket options. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int[in]level

- Set the socket option, take the socket level

int[in]option_name

- Provide the name of the ID. 1.SO_MAX_RETRY - Select TCP max retry count 2.SO_SOCK_VAP_ID - Select the VAP id 3.SO_TCP_KEEP_ALIVE - Configure the TCP keep alive initial time 4.SO_RCVBUF - Configure the application buffer for receiving server certificate 5.SO_SSL_ENABLE-Configure SSL socket 6.SO_HIGH_PERFORMANCE_SOCKET-Configure high performance socket 7.IP_TOS - Configure the type of service value [0-7]

TOS

Value Description

0

Best Effort

1

Priority

2

Immediate

3

Flash-mainly used for voice signaling

4

Flash Override

5

Critical - mainly used for voice RTP (Real-time Tranlocal_port Protocol)

6

Internet

7

Network

8.SO_TLS_SNI for configuring the SNI feature 9.SO_RCVTIMEO: Configure the socket-receive timeout using this option. If no data is received within this time, the sapi driver will unblock this API.

const void *[in]option_value

- Value of the parameter

rsi_socklen_t[in]option_len

- Length of the parameter

Returns

  • 0 - Success

  • Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc)

Note

  • Precondition - rsi_socket() API needs to be called before this API.

  • Default window size is 2920 bytes. To modify window size, user need to configure HIGH_PERFORMANCE socket as option_name in rsi_setsockopt() API


References SL_PRINTF , RSI_SUCCESS , rsi_wlan_socket_set_status , rsi_set_os_errno , rsi_socket_info_non_rom_s::max_tcp_retries , rsi_uint16_to_2bytes , rsi_socket_info_non_rom_s::ssl_bitmap , rsi_socket_info_s::sock_bitmap , rsi_socket_info_s::max_available_buffer_count , rsi_socket_info_s::current_available_buffer_count , rsi_socket_info_s::socket_cert_inx , rsi_socket_info_non_rom_s::high_performance_socket , rsi_socket_info_non_rom_s::vap_id , rsi_socket_info_non_rom_s::tcp_mss , rsi_socket_info_non_rom_s::tcp_retry_transmit_timer , rsi_socket_info_non_rom_s::max_retransmission_timeout_value , rsi_socket_info_s::recv_buffer , rsi_socket_info_s::recv_buffer_length , rsi_fill_tls_extension , rsi_socket_info_non_rom_s::tos , rsi_socket_info_non_rom_s::ssl_buff_len , rsi_timeval::tv_sec , rsi_timeval::tv_usec , and rsi_socket_info_s::read_time_out

rsi_getsockopt#

int rsi_getsockopt (int32_t sockID, int level, int option_name, const void * option_value, rsi_socklen_t option_len)

Get the socket options. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int[in]level

- Set the socket option, take the socket level

int[in]option_name

- Provide the name of the ID

const void *[in]option_value

- Value of the parameter

rsi_socklen_t[in]option_len

- Length of the parameter

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note

  • Precondition - rsi_socket() API needs to be called before this API.


rsi_select#

int32_t rsi_select (int32_t nfds, rsi_fd_set * readfds, rsi_fd_set * writefds, rsi_fd_set * exceptfds, struct rsi_timeval * timeout, void(*)(rsi_fd_set *fd_read, rsi_fd_set *fd_write, rsi_fd_set *fd_except, int32_t status) callback, fd_read, fd_write, fd_except, status)

Monitor multiple socket (file descriptors), waiting until one or more of the sockets become ready to perform receive or send operation. If callback is NULL or not provided, it is a blocking API. Otherwise, it is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]nfds

- The highest-numbered file descriptor in any of the three sets, plus 1

rsi_fd_set *[in]readfds

- Socket descriptors to watch to see if data become available for receive

rsi_fd_set *[in]writefds

- Socket descriptors to watch to see if space is available in socket to send data.

rsi_fd_set *[in]exceptfds

- Socket descriptors to watch for exception

struct rsi_timeval *[in]timeout

- Timeout value to break the wait for select. If both fields of the timeval structure are zero, then select() returns immediately. (This is useful for polling). If timeout is NULL (no timeout), rsi_select() can block indefinitely.

void(*)(rsi_fd_set *fd_read, rsi_fd_set *fd_write, rsi_fd_set *fd_except, int32_t status)[in]callback

- Callback called when asynchronous response reach the select request.

[out]fd_read

- Pointer that holds bitmap for the select on read operation

[out]fd_write

- Pointer that holds bitmap for the select on write operation

[out]fd_except

- Pointer that holds bitmap for the select on exceptional operation

[out]status

- Status code

Returns

  • Positive Value - Indicate total number of bits ready across all the descriptor sets

  • 0 - Time out

  • Negative Value - Failure

Note


calculate_buffers_required#

uint8_t calculate_buffers_required (uint8_t type, uint16_t length)

Calculate the buffers required.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]type

- Type

uint16_t[in]length

- Length

Returns

  • 0 - Success

  • Non-Zero Value - Failure


rsi_accept_async#

int32_t rsi_accept_async (int32_t sockID, void(*)(int32_t sock_id, int16_t dest_port, uint8_t *ip_addr, int16_t ip_version) callback, sock_id, dest_port, ip_addr, ip_version)

Accept the connection request from the remote peer and register a callback that will be used by the driver to forward the received connection request asynchronously to the application. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

void(*)(int32_t sock_id, int16_t dest_port, uint8_t *ip_addr, int16_t ip_version)[in]callback

- Callback function to indicate the socket parameters connected

[out]sock_id

- Socket descriptor ID

[out]dest_port

- Port number of remote peer

[out]ip_addr

- Remote peer address

[out]ip_version

- 4 - IPV4. 6 - IPV6

Returns

  • > 0 - Client socket ID

  • <= 0 - Failure

Note

  • When attempting to connect multiple clients to the server socket opened on module, i.e., when the backlog parameter is used in rsi_listen() API. rsi_accept_async() has to be called again for each of the client connections. The API calling has to be repeated for the next client connection, only after the connection process of the previous client is complete.

  • When using multiple client/server sockets, the following macros have to be updated in the wlan_config.h file, in TCP_IP_FEATURE_BIT_MAP - If TCP_IP_TOTAL_SOCKETS_x flag is used, then firmware allocates memory for x sockets. If TCP_IP_TOTAL_SOCKETS_x flag is not passed, then a default value of 10 sockets is used.

  • When using multiple client/server sockets, the following macros have to be updated in the rsi_user.h file, RSI_NUMBER_OF_LTCP_SOCKETS -> Number of server sockets and RSI_NUMBER_OF_SOCKETS -> Number of client sockets + Number of server sockets.

  • If multiple server sockets are created then the memory allocated for client sockets is to be shared across the multiple server sockets. If RSI_NUMBER_OF_LTCP_SOCKETS is 0 and RSI_NUMBER_OF_SOCKETS is x, y is server sockets and x-y client sockets can be created


rsi_get_app_socket_descriptor#

int32_t rsi_get_app_socket_descriptor (uint8_t * src_port)

Get the application socket descriptor from source port.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[in]src_port

- Pointer to the socket source port

Returns

  • Positive Value - Application socket descriptor

  • Negative Value - If socket is not found


rsi_get_socket_id#

int32_t rsi_get_socket_id (uint32_t src_port, uint32_t dst_port)

Get the socket ID from port number.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]src_port

- Socket source port number

uint32_t[in]dst_port

- Socket destination port number

Returns

  • Positive Value - Socket descriptor

  • Negative Value - If socket is not found


rsi_get_primary_socket_id#

int32_t rsi_get_primary_socket_id (uint8_t * port_num)

Get the primary socket ID from port number.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[in]port_num

- Pointer to port number

Returns

  • Positive Value - Socket descriptor

  • Negative Value - If socket is not found


rsi_certificate_valid#

int32_t rsi_certificate_valid (uint16_t valid, uint16_t socket_id)

Validate the server certificate received from the module. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
uint16_t[in]valid

- Indicate whether the server certificate is valid or not. 1 - Indicate that the server certificate is valid. 0 - Indicate that the server certificate is not valid

uint16_t[in]socket_id

- Socket identifier

Returns

  • 0 - Success

  • Negative Value - Failure


rsi_socket_create_async#

int32_t rsi_socket_create_async (int32_t sockID, int32_t type, int32_t backlog, backlog)

Send socket create request to the module and receive the response asynchronously. This is a non-blocking API if socket_connect_response_handler is registered. Otherwise it is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Pointer to the global control block

int32_t[in]type

- Socket descriptor ID

int32_t[in]backlog

- Type of socket to create

[in]backlog

- Number of backlogs for LTCP socket

Returns

  • 0 - Success

  • Negative Value - Failure

Note

  • Precondition - rsi_connect() API needs to be called before this API.


rsi_get_socket_descriptor#

int32_t rsi_get_socket_descriptor (uint8_t * src_port, uint8_t * dst_port, uint8_t * ip_addr, uint16_t ip_version, uint16_t sockid)

Get the socket descriptor based on source port number, destination port number, destination IP address, and the IP version. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[in]src_port

- Pointer to source port number

uint8_t *[in]dst_port

- Pointer to destination port number

uint8_t *[in]ip_addr

- Pointer to destinaion IP address

uint16_t[in]ip_version

- IP version either IPv4/IPv6

uint16_t[in]sockid

- Socket descriptor ID from firmware

Returns

  • 0 - Socket descriptor

  • Negative Value - If socket is not found


rsi_socket_async_non_rom#

int32_t rsi_socket_async_non_rom (int32_t protocolFamily, int32_t type, int32_t protocol, void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length) callback, sock_no, buffer, length)

Create a socket and register a callback that will be used by the driver to forward the received packets asynchronously to the application (on packet reception) without waiting for recv API (Add proper API here). This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]protocolFamily

- Protocol family to select IPv4 or IPv6. AF_INET (2) : Select IPv4, AF_INET6 (3) : Select IPv6

int32_t[in]type

- Select socket type UDP or TCP. SOCK_STREAM (1) : Select TCP, SOCK_DGRM (2) : Select UDP

int32_t[in]protocol

- 0: Non-SSL sockets, 1: SSL sockets. BIT(5) must be enabled to select the certificate index, 0<<12 for index 0, 1<<12 for index 1

void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length)[in]callback

- Callback function to read data asynchronously from socket

[out]sock_no

- Application socket number

[out]buffer

- Pointer to buffer holding the data

[out]length

- Length of the response buffer

Returns

  • 0 - Success

  • Negative Value - Failure

Note


Referenced by rsi_socket_async , and rsi_socket

rsi_socket_connect#

int32_t rsi_socket_connect (int32_t sockID, struct rsi_sockaddr * remoteAddress, int32_t addressLength)

Connect the socket to specific remote address. This is a non-blocking API, if socket_connect_response_handler() is registered through rsi_wlan_register_callbacks(). Otherwise it is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

struct rsi_sockaddr *[in]remoteAddress

- Remote peer address structure

int32_t[in]addressLength

- Remote peer address structrue length

Returns

  • 0 - Success

  • Negative Value - Failure


rsi_socket_recvfrom#

int32_t rsi_socket_recvfrom (int32_t sockID, int8_t * buffer, int32_t buffersize, int32_t flags, struct rsi_sockaddr * fromAddr, int32_t * fromAddrLen)

Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int8_t *[out]buffer

- Pointer to buffer to hold receive data

int32_t[in]buffersize

- Size of the buffer supplied

int32_t[in]flags

- Reserved

struct rsi_sockaddr *[out]fromAddr

- Sddress of remote peer, from where current packet was received

int32_t *[in]fromAddrLen

- Pointer that contains remote peer address (fromAddr) length

Returns

  • Positive Value - Number of bytes received successfully

  • 0 - Socket close error

  • Negative Value - Failure

Note


rsi_socket_listen#

int32_t rsi_socket_listen (int32_t sockID, int32_t backlog)

Enable socket to listen for remote connection request in passive mode. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int32_t[in]backlog

- Maximum number of pending connections requests

Returns

  • 0 - Success

  • Negative Value - Failure


rsi_vap_sockets_shutdown#

int32_t rsi_vap_sockets_shutdown (uint8_t vapID)

Close all the sockets associated with a VAP Id. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]vapID

: Virtual Access Point ID

Note

  • If EXT_TCP_IP_WAIT_FOR_SOCKET_CLOSE (BIT(16)) in RSI_EXT_TCPIP_FEATURE_BITMAP is enabled, though remote socket has terminated connection, socket is disconnected and deleted only if host issues rsi_shutdown().

Returns

  • 0 - Success Negative Value - Failure


rsi_socket_shutdown#

int32_t rsi_socket_shutdown (int32_t sockID, int32_t how)

Close the socket specified in a socket descriptor. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

: Socket descriptor ID

int32_t[in]how

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

Returns

  • 0 - Success

  • Negative Value - Failure

Note

  • Precondition - rsi_socket()/ rsi_socket_async() API needs to be called before this API.

  • how = 1 is valid for passively open sockets (listen) with more than one backlogs specified.

  • If EXT_TCP_IP_WAIT_FOR_SOCKET_CLOSE (BIT(16)) in RSI_EXT_TCPIP_FEATURE_BITMAP is enabled, then to close LTCP socket, argument "how" should be 1.

  • If EXT_TCP_IP_WAIT_FOR_SOCKET_CLOSE (BIT(16)) in RSI_EXT_TCPIP_FEATURE_BITMAP is enabled, though remote socket has terminated connection, socket is disconnected and deleted only, if host issues rsi_shutdown().


rsi_socket_bind#

int32_t rsi_socket_bind (int32_t sockID, struct rsi_sockaddr * localAddress, int32_t addressLength)

Assign address to the socket. This is a non-blocking API for TCP and a blocking API for UDP.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

struct rsi_sockaddr *[in]localAddress

- Address that needs to be assigned

int32_t[in]addressLength

- Length of the socket address

Returns

  • 0 - Success

  • Negative Value - Failure


rsi_wait_on_socket_semaphore#

rsi_error_t rsi_wait_on_socket_semaphore (rsi_semaphore_handle_t * semaphore, uint32_t timeout_ms)

Wait for network semaphore.

Parameters
TypeDirectionArgument NameDescription
rsi_semaphore_handle_t *[in]semaphore

- Semaphore handle pointer

uint32_t[in]timeout_ms

- Maximum time to wait to acquire semaphore. If timeout_ms is 0, then wait till semaphore is acquired.

Returns

  • 0 - Success

  • Negative Value - Failure


rsi_application_socket_descriptor#

int32_t rsi_application_socket_descriptor (int32_t sock_id)

Get the application socket descriptor from module’s socket descriptor. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sock_id

- Module's socket descriptor ID

Returns

  • Positive Value - Application socket descriptor

  • Negative Value - If socket is not found


rsi_wlan_socket_get_status#

int32_t rsi_wlan_socket_get_status (int32_t sockID)

Get WLAN socket status. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Application socket ID

Returns

  • WLAN socket status


rsi_wlan_socket_set_status#

void rsi_wlan_socket_set_status (int32_t status, int32_t sockID)

Set WLAN status. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]status

- Status value to be set

int32_t[in]sockID

- Application socket ID

Returns

  • Void


rsi_select_get_status#

int32_t rsi_select_get_status (int32_t selectid)

Get the status of the socket specified in the select ID.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]selectid

- Socket ID to get the status

Returns

  • 0 - Success

  • Negative Value - Failure


rsi_select_set_status#

void rsi_select_set_status (int32_t status, int32_t selectid)

Set the status of the socket specified in the select ID.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]status

- Status value to be set

int32_t[in]selectid

- Socket ID on which the status is set

Returns

  • Void

Note


rsi_send_async_non_rom#

int32_t rsi_send_async_non_rom (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags, void(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)

Send data on a given socket asynchronously.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

const int8_t *[in]msg

- Pointer to data that needs to be sent to remote peer

int32_t[in]msgLength

- Length of data to send

int32_t[in]flags

- Reserved

void(*)(int32_t sockID, uint16_t length)[in]data_transfer_complete_handler

- Pointer to callback function called after complete data transfer

[out]sockID

- Socket Descriptor ID

[out]length

- Number of bytes transfered

Returns

  • 0 - Success

  • Negative Value - Failure

Note

  • The following table lists the maximum individual chunk of data that can be sent over each supported protocol.

Protocol

Maximum data chunk (bytes)

TCP/LTCP socket

1460

LUDP socket

1472

Web socket

1450

TCP-SSL/LTCP-SSL

1370

Web socket over SSL

1362


rsi_sendto_async_non_rom#

int32_t rsi_sendto_async_non_rom (int32_t sockID, int8_t * msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr * destAddr, int32_t destAddrLen, void(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)

Send data to specific remote peer on a given socket.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

int8_t *[in]msg

- Pointer to data that needs to be sent to remote peer

int32_t[in]msgLength

- Length of data to send

int32_t[in]flags

- Reserved

struct rsi_sockaddr *[in]destAddr

- Remote peer address to send data

int32_t[in]destAddrLen

- Remote peer address length

void(*)(int32_t sockID, uint16_t length)[in]data_transfer_complete_handler

- Pointer to callback function called after complete data transfer

[out]sockID

- Socket Descriptor ID

[out]length

- Number of bytes transfered

Returns

  • Positive Value - Success, Number of bytes sent successfully

  • Negative Value - Failure

  • 0 - Socket close error


rsi_clear_sockets_non_rom#

void rsi_clear_sockets_non_rom (int32_t sockID)

Clear socket information.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]sockID

- Socket descriptor ID

Returns

  • Void


ROM_WL_rsi_get_application_socket_descriptor#

int32_t ROM_WL_rsi_get_application_socket_descriptor (global_cb_t * global_cb_p, int32_t sock_id)

Get the application socket descriptor from module’s socket descriptor. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
global_cb_t *[in]global_cb_p

- Pointer to the global control block

int32_t[in]sock_id

- Module's socket descriptor

Returns

  • Positive value - Application socket descriptor

  • Negative value - If socket is not found


ROM_WL_rsi_get_primary_socket_id#

int32_t ROM_WL_rsi_get_primary_socket_id (global_cb_t * global_cb_p, uint16_t port_number)

Get socket descriptor from port_number. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
global_cb_t *[in]global_cb_p

- Pointer to the global control block

uint16_t[in]port_number

- Port number

Returns

  • Positive value - Socket descriptor

  • Negative value - If socket is not found


ROM_WL_calculate_buffers_required#

uint8_t ROM_WL_calculate_buffers_required (global_cb_t * global_cb_p, uint8_t type, uint16_t length)

Calculate number of buffers required for the data packet. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
global_cb_t *[in]global_cb_p

- Pointer to the global control block

uint8_t[in]type

- Type of socket to create

uint16_t[in]length

- Length of the message

Returns

  • Number of buffers required for the data packet


ROM_WL_calculate_length_to_send#

uint16_t ROM_WL_calculate_length_to_send (global_cb_t * global_cb_p, uint8_t type, uint8_t buffers)

Calculate the length available in the buffers for the message. This is a non-blocking API.

Parameters
TypeDirectionArgument NameDescription
global_cb_t *[in]global_cb_p

- Pointer to the global control block

uint8_t[in]type

- Type of the socket stream

uint8_t[in]buffers

- Available buffers

Returns

  • Length available in the buffers for message


rsi_socket_config#

int32_t rsi_socket_config (void )

Set the socket configuration parameters. The configurations can be done using the Socket configuration in the rsi_wlan_config.h file. Using this API is highly recommended. Based on the socket configuration, module will use available buffers effectively. This is a blocking API.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • 0 - Success

  • Non-Zero Value - Failure (Possible Error Codes - 0x0021, 0x0025, 0x002C, 0xFF6D)

Note

  • Precondition - rsi_config_ipaddress() API and socket creation should be done before this API is called.

  • The following parameters are provided by user,

    Parameters

    Description

    total socket

    Desired total number of sockets to open

    total_tcp_sockets

    Desired total number of TCP sockets to open

    total_udp_sockets

    Desired total number of UDP sockets to open

    tcp_tx_only_sockets

    Desired total number of TCP sockets to open which are used only for data transmission

    tcp_rx_only_sockets

    Desired total number of TCP sockets to open which are used only for data reception

    udp_tx_only_sockets

    Desired total number of UDP sockets to open which are used only for data transmission

    udp_rx_only_sockets

    Desired total number of UDP sockets to open which are used only for data reception

    tcp_rx_high_performance_sockets

    Desired total number of high performance TCP sockets to open. High performance sockets can be

    ^ allocated with more buffers based on the buffers availability. This option is valid only for TCP ^ data receive sockets. Socket can be opened as high performance by setting high performance bit in ^ socket create command. tcp_rx_window_size_cap | Desired total to increase the TCP RX window size tcp_ack_window_div_factor | In case of high latency networks to configure the TCP ACK division factor with respective to the ^ window size; Increases the ACK frequency for asynchronous sockets ^ Note: ^ Default value is tcp_rx_window_size_cap.

  • The following conditions must be met:

  • total_sockets <= Maximum allowed sockets(10)

  • (total_tcp_sockets + total_udp_sockets) <= total_sockets

  • (total_tcp_tx_only_sockets + total_tcp_rx_only_sockets) <= total_tcp_sockets

  • (total_udp_tx_only_sockets + total_udp_rx_only_sockets) <= total_udp_sockets

  • total_tcp_rx_high_performance_sockets <= total_tcp_rx_only_sockets

  • Refer to Error Codes for the description of above error codes.