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(*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.

Parameters
[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

[in]server_ip_addr

- Web server IP address

[in]server_port

- Web server socket port

[in]device_port

- Local port

[in]webs_resource_name

- Web resource name

[in]webs_host_name

- Web host name

[in]socket_id

- Socket ID

[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


Definition at line 49 of file network/protocols/rsi_web_socket.c

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
[in]sockID

- Application socket ID

[in]opcode

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

[in]msg

- Data

[in]msg_length

- Data length

Returns

  • 0 - Success

  • Negative Value - Failure

Note


Definition at line 347 of file network/protocols/rsi_web_socket.c

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
[in]sockID

- Socket ID of particular socket

Returns

  • 0 - Success

  • Negative Value - Failure

Note


Definition at line 368 of file network/protocols/rsi_web_socket.c

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
[in]fd

- Socket ID

[in]fds_p

- Pointer to the rsi_fd_set_s structure

Returns

  • Positive Value - Success

  • 0 - Failure


Definition at line 58 of file network/socket/rsi_socket.c

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
[in]fd

- Socket id

[in]fds_p

- Pointer to the rsi_fd_set_structure

Returns

  • Void


Definition at line 77 of file network/socket/rsi_socket.c

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
[in]fd

- Socket ID

[in]fds_p

- Pointer to the rsi_fd_set_s structure

Returns

  • Void


Definition at line 96 of file network/socket/rsi_socket.c

rsi_socket_async#

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.

Parameters
[in]protocolFamily

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

[in]type

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

[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.

[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


Definition at line 134 of file network/socket/rsi_socket.c

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
[in]protocolFamily

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

[in]type

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

[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


Definition at line 168 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]localAddress

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

[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.


Definition at line 207 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]remoteAddress

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

[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.


Definition at line 230 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[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


Definition at line 254 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]ClientAddress

- Remote peer address

[in]addressLength

- Length of the address measured in bytes

Returns

  • > 0 - Client socket ID

  • <= 0 - Failure

Note


Definition at line 272 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor

[in]ClientAddress

- Remote peer address

[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.


Definition at line 514 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor

[in]buffer

- Pointer to buffer to hold receive data

[in]requested_length

- Requested buffer length

[in]flags

- Reserved

[in]fromAddr

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

[in]fromAddrLen

- Pointer that contains remote peer address (fromAddr) length

Returns

  • Number of bytes received successfully – Success

  • Negative value – Failure

  • 0 – Socket close error


Definition at line 535 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor

[in]buffer

- Pointer to buffer to hold receive data

[in]buffersize

- Size of the buffer supplied

[in]flags

- Reserved

[in]fromAddr

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

[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


Definition at line 619 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]rcvBuffer

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

[in]bufferLength

- Length of the buffer

[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


Definition at line 670 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]msg

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

[in]msgLength

- Length of the buffer

[in]flags

- Reserved

[in]destAddr

- Address of the remote peer to send data

[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


Definition at line 729 of file network/socket/rsi_socket.c

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(*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.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

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

[in]msgLength

- Length of data to send

[in]flags

- Reserved

[in]destAddr

- Address of the remote peer to send data

[in]destAddrLen

- Length of the address in bytes

[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.


Definition at line 772 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]msg

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

[in]msgLength

- Length of the buffer

[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


Definition at line 812 of file network/socket/rsi_socket.c

rsi_reset_per_socket_info#

void rsi_reset_per_socket_info (int32_t sockID)

Reset all the socket related information.

Parameters
[in]sockID

- Socket descriptor ID

Returns

  • Void


Definition at line 838 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]msg

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

[in]msgLength

- Length of data to send

[in]flags

- Reserved

Returns

  • 0 - Success

  • Non-Zero Value - Failure


Definition at line 864 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]length

- Length of data to send

Returns

  • Void


Definition at line 930 of file network/socket/rsi_socket.c

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(*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.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

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

[in]msgLength

- Length of data to send

[in]flags

- Reserved

[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


Definition at line 1023 of file network/socket/rsi_socket.c

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
[in]event_map

- Event map

Returns

  • Socket ID from the event map


Definition at line 1109 of file network/socket/rsi_socket.c

rsi_socket_event_handler#

void rsi_socket_event_handler (void)

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

Parameters
[in]

Returns

  • Void


Definition at line 1132 of file network/socket/rsi_socket.c

rsi_send_async#

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.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

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

[in]msgLength

- Length of the buffer

[in]flags

- Reserved

[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.


Definition at line 1177 of file network/socket/rsi_socket.c

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
[in]vapID

- Virtual access point ID

Returns

  • 0 - Success Negative Value - Failure


Definition at line 1201 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[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


Definition at line 1224 of file network/socket/rsi_socket.c

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
[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)


Definition at line 1278 of file network/socket/rsi_socket.c

rsi_clear_sockets#

void rsi_clear_sockets (int32_t sockID)

Clear socket information.

Parameters
[in]sockID

- Socket descriptor ID

Returns

  • Void


Definition at line 1292 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]extension_type

- Type of TLS extension

[in]option_value

- TLS extension data

[in]extension_len

- TLS extension data length

Returns

  • 0 - Success

  • Non-Zero Value - Failure


Definition at line 1311 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]level

- Set the socket option, take the socket level

[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.

[in]option_value

- Value of the parameter

[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


Definition at line 1379 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]level

- Set the socket option, take the socket level

[in]option_name

- Provide the name of the ID

[in]option_value

- Value of the parameter

[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.


Definition at line 1652 of file network/socket/rsi_socket.c

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(*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.

Parameters
[in]nfds

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

[in]readfds

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

[in]writefds

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

[in]exceptfds

- Socket descriptors to watch for exception

[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.

[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


Definition at line 1740 of file network/socket/rsi_socket.c

calculate_buffers_required#

uint8_t calculate_buffers_required (uint8_t type, uint16_t length)

Calculate the buffers required.

Parameters
[in]type

- Type

[in]length

- Length

Returns

  • 0 - Success

  • Non-Zero Value - Failure


Definition at line 1980 of file network/socket/rsi_socket.c

rsi_accept_async#

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.

Parameters
[in]sockID

- Socket descriptor ID

[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


Definition at line 2012 of file network/socket/rsi_socket.c

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
[in]src_port

- Pointer to the socket source port

Returns

  • Positive Value - Application socket descriptor

  • Negative Value - If socket is not found


Definition at line 2178 of file network/socket/rsi_socket.c

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
[in]src_port

- Socket source port number

[in]dst_port

- Socket destination port number

Returns

  • Positive Value - Socket descriptor

  • Negative Value - If socket is not found


Definition at line 2211 of file network/socket/rsi_socket.c

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
[in]port_num

- Pointer to port number

Returns

  • Positive Value - Socket descriptor

  • Negative Value - If socket is not found


Definition at line 2241 of file network/socket/rsi_socket.c

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
[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

[in]socket_id

- Socket identifier

Returns

  • 0 - Success

  • Negative Value - Failure


Definition at line 2282 of file network/socket/rsi_socket.c

rsi_socket_create_async#

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.

Parameters
[in]sockID

- Pointer to the global control block

[in]type

- Socket descriptor ID

[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.


Definition at line 2346 of file network/socket/rsi_socket.c

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
[in]src_port

- Pointer to source port number

[in]dst_port

- Pointer to destination port number

[in]ip_addr

- Pointer to destinaion IP address

[in]ip_version

- IP version either IPv4/IPv6

[in]sockid

- Socket descriptor ID from firmware

Returns

  • 0 - Socket descriptor

  • Negative Value - If socket is not found


Definition at line 2677 of file network/socket/rsi_socket.c

rsi_socket_async_non_rom#

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.

Parameters
[in]protocolFamily

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

[in]type

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

[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

[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


Definition at line 2785 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]remoteAddress

- Remote peer address structure

[in]addressLength

- Remote peer address structrue length

Returns

  • 0 - Success

  • Negative Value - Failure


Definition at line 2970 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[out]buffer

- Pointer to buffer to hold receive data

[in]buffersize

- Size of the buffer supplied

[in]flags

- Reserved

[out]fromAddr

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

[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


Definition at line 3104 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]backlog

- Maximum number of pending connections requests

Returns

  • 0 - Success

  • Negative Value - Failure


Definition at line 3385 of file network/socket/rsi_socket.c

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
[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


Definition at line 3482 of file network/socket/rsi_socket.c

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
[in]sockID

: Socket descriptor ID

[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().


Definition at line 3515 of file network/socket/rsi_socket.c

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
[in]sockID

- Socket descriptor ID

[in]localAddress

- Address that needs to be assigned

[in]addressLength

- Length of the socket address

Returns

  • 0 - Success

  • Negative Value - Failure


Definition at line 3660 of file network/socket/rsi_socket.c

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
[in]semaphore

- Semaphore handle pointer

[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


Definition at line 3815 of file network/socket/rsi_socket.c

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
[in]sock_id

- Module's socket descriptor ID

Returns

  • Positive Value - Application socket descriptor

  • Negative Value - If socket is not found


Definition at line 3844 of file network/socket/rsi_socket.c

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
[in]sockID

- Application socket ID

Returns

  • WLAN socket status


Definition at line 3879 of file network/socket/rsi_socket.c

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
[in]status

- Status value to be set

[in]sockID

- Application socket ID

Returns

  • Void


Definition at line 3893 of file network/socket/rsi_socket.c

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
[in]selectid

- Socket ID to get the status

Returns

  • 0 - Success

  • Negative Value - Failure


Definition at line 3909 of file network/socket/rsi_socket.c

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
[in]status

- Status value to be set

[in]selectid

- Socket ID on which the status is set

Returns

  • Void

Note


Definition at line 3929 of file network/socket/rsi_socket.c

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(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data on a given socket asynchronously.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

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

[in]msgLength

- Length of data to send

[in]flags

- Reserved

[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


Definition at line 3961 of file network/socket/rsi_socket.c

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(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data to specific remote peer on a given socket.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

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

[in]msgLength

- Length of data to send

[in]flags

- Reserved

[in]destAddr

- Remote peer address to send data

[in]destAddrLen

- Remote peer address 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


Definition at line 4045 of file network/socket/rsi_socket.c

rsi_clear_sockets_non_rom#

void rsi_clear_sockets_non_rom (int32_t sockID)

Clear socket information.

Parameters
[in]sockID

- Socket descriptor ID

Returns

  • Void


Definition at line 4264 of file network/socket/rsi_socket.c

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
[in]global_cb_p

- Pointer to the global control block

[in]sock_id

- Module's socket descriptor

Returns

  • Positive value - Application socket descriptor

  • Negative value - If socket is not found


Definition at line 33 of file network/socket/rsi_socket_rom.c

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
[in]global_cb_p

- Pointer to the global control block

[in]port_number

- Port number

Returns

  • Positive value - Socket descriptor

  • Negative value - If socket is not found


Definition at line 63 of file network/socket/rsi_socket_rom.c

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
[in]global_cb_p

- Pointer to the global control block

[in]type

- Type of socket to create

[in]length

- Length of the message

Returns

  • Number of buffers required for the data packet


Definition at line 92 of file network/socket/rsi_socket_rom.c

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
[in]global_cb_p

- Pointer to the global control block

[in]type

- Type of the socket stream

[in]buffers

- Available buffers

Returns

  • Length available in the buffers for message


Definition at line 143 of file network/socket/rsi_socket_rom.c

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
N/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.


Definition at line 7902 of file wlan/rsi_wlan_apis.c