BSD Sockets#
Functions#
Create a web socket client. This is a blocking API.
Send data from the web socket client. This is a non-blocking API.
Close the web socket client. This is a non-blocking API.
Check for the bit set in the bitmap. This is a non-blocking API.
Set the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.
Clear the bit in the bitmap. This is a non-blocking API.
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 call. This is a non-blocking API.
Create and return a socket instance, also referred to as an endpoint of communication. This is a non-blocking API.
Assign an address to a socket. This is a non-blocking API for TCP and a blocking API for UDP.
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.
Enable socket to listen for a remote connection request in passive mode. This is a blocking API.
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.
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.
Receive large data on a given socket synchronously.
Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.
Retrieve the data from the remote peer on a specified socket. This is a blocking API.
This API sends data to the specified remote IP Address on the given socket. This is non-blocking API.
This API sends the data to the specified remote IP Address on the given socket and receives the acknowledgement through the registered call back. This is non-blocking API.
This API sends the data to the remote peer on the given socket. This is a non-blocking API.
Reset all the socket related information.
Send large data on a given socket synchronously.
Callback function used to send one chunk of data at a time.
Send large data on a given socket. This is a blocking API.
Find which socket the data is pending, according to the event that is set from the map.
Retrieve the packet from protocol TX data pending queue and forward to the module.
Send data on a given socket asynchronously.
Closes the socket specified in a socket descriptor. This is a blocking API.
Get the application socket descriptor from module socket descriptor.
Clear socket information.
Configure TLS extensions.
Set the socket options. This is a non-blocking API.
Get the socket options. This is a non-blocking API.
Select is a BSD API which allow a program to 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.
Calculate the buffers required.
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.
Get the application socket descriptor from available socket pool.
Function to get the primary socket ID from port number.
Get the primary socket ID from port number.
Host indicate the status to module after validating the server certificate received from module. This is a non-blocking API.
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.
Get the primary socket ID based on source port number, destination port number, destination IP address, and the IP version. This is a non-blocking API.
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 call. This is a non-blocking API.
Connect the socket to 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.
Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.
Enable socket to listen for remote connection request in passive mode. This is a blocking API.
Close the socket specified in a socket descriptor. This is a blocking API.
Assign address to the socket. This is a non-blocking API for TCP and a blocking API for UDP.
Wireless Library to acquire or wait for NWK semaphore.
Get the application socket descriptor from module socket descriptor. This is a non-blocking API.
Return WLAN status. This is a non-blocking API.
Set WLAN status. This is a non-blocking API.
Get the status of the socket specified in the select ID.
Set the status of the socket specified in the select ID.
Send data on a given socket asynchronously.
Send data to specific remote peer on a given socket.
Clear socket information.
Get the application socket descriptor from module socket descriptor. This is a non-blocking API.
Get socket descriptor from port_number. This is a non-blocking API.
Calculate number of buffers required for the data packet. This is a non-blocking API.
Caluculate the msg length sent using available buffers. This is a non-blocking API.
Set the socket configuration parameters. Using this command (optional) 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.
[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 |
rsi_config_ipaddress() API needs to be called before this API.
Returns
Zero - Success Negative Value - Failure -2 - Invalid parameter -4 - Buffer not available to serve the command
51
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.
[in] | sockID | - Application socket id |
[in] | opcode | - opcode (type of the packet to be included in web socket header). |
[in] | msg | - Data |
[in] | msg_length | - Data length |
rsi_config_ipaddress() API needs to be called before this API.
Returns
0 - Success Negative Value - Failure
350
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.
[in] | sockID | - Socket id of particular socket |
rsi_config_ipaddress() API needs to be called before this API
Returns
0 - Success Negative Value - Failure
372
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 set in the bitmap. This is a non-blocking API.
[in] | fd | - Socket id |
[in] | fds_p | - Pointer to the rsi_fd_set_s structure |
Returns
Positive Value - Success Zero - Failure
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.
[in] | fd | - Socket id |
[in] | fds_p | - Pointer to the rsi_fd_set_structure |
Returns
Void
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 in the bitmap. This is a non-blocking API.
[in] | fd | - Socket id |
[in] | fds_p | - Pointer to the rsi_fd_set_s structure |
Returns
Void
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(*)(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 call. This is a non-blocking API.
[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 |
rsi_config_ipaddress() API needs to be called before this API.
Returns
Succes - RSI_SUCCESS Failure - Negative Value Possible error codes : 0xFFF8, 0xFF80, 0xFF6D, 0xFF85, 0xBB33, 0xBB22
Note
Refer to Error Codes section for the description of the above error codes Error Codes.
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, also referred to as an endpoint of communication. This is a non-blocking API.
[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. |
rsi_config_ipaddress() API needs to be called before this API.
Returns
Success - Return sock_id of the created socket Failure - Non-Zero value
RSI_ERROR_COMMAND_GIVEN_IN_WRONG_STATE - Command entered in wrong state
RSI_SOCK_ERROR - Error in creating socket
172
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.
[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 |
rsi_socket() or API needs to be called before this API.
Returns
Zero - Success Negative Value - Failure
211
of file network/socket/rsi_socket.c
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.
[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 |
rsi_socket() or rsi_bind() API needs to be called before this API.
Returns
Zero - Success Negative Value - Failure
Note
For asynchronous behaviour, user needs to register RSI_WLAN_SOCKET_CONNECT_NOTIFY_CB callback id.
234
of file network/socket/rsi_socket.c
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.
[in] | sockID | - Socket descriptor ID |
[in] | backlog | - Maximum length to which the queue of pending connections can be held |
rsi_bind() API needs to be called before this API.
Returns
Zero - Success Negative Value - Failure
256
of file network/socket/rsi_socket.c
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.
[in] | sockID | - Socket descriptor ID |
[in] | ClientAddress | - Remote peer address |
[in] | addressLength | - Length of the address measured in bytes |
rsi_socket()/ rsi_socket_async() API needs to be called before this API.
Returns
Zero - Success Negative Value - Failure
275
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.
[in] | sockID | - Socket descriptor |
[in] | ClientAddress | - Remote peer address |
[in] | addressLength | - Length of the address measured in bytes |
rsi_listen()/ API needs to be called before this API.
Returns
Zero - Success Negative Value - Failure
517
of file network/socket/rsi_socket.c
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.
[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
Positive Value - Success, returns the number of bytes received successfully Negative Value - Failure zero - Socket close error
538
of file network/socket/rsi_socket.c
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.
[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 |
rsi_socket()/ rsi_socket_async() API needs to be called before this API.
Returns
Positive Value - Success, returns the number of bytes received successfully Negative Value - Failure zero - Socket close error
624
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.
[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 |
For tcp_client rsi_connect() API needs to be called before this API. For tcp_server rsi_listen() and rsi_connect()/ API needs to be called before this API. For udp_server rsi_bind() API needs to be called before this API. For udp_client rsi_socket() or rsi_bind() API needs to be called before this API
Returns
Positive Value - Success, returns the number of bytes received successfully Negative Value - Failure zero - Socket close error
675
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)
This API sends data to the specified remote IP Address on the given socket. This is non-blocking API.
[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 |
For tcp_client, rsi_connect() For tcp_server, rsi_listen() and rsi_accept()/ API needs to be called before this API. For udp_server rsi_bind() API needs to be called before this API. For udp_client rsi_socket() or rsi_bind() API needs to be called before this API
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 |
Returns
Positive Value - Success, returns the number of bytes sent successfully Negative Value - Failure zero - Socket close error
735
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(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, length)
This API sends the data to the specified remote IP Address on the given socket and receives the acknowledgement through the registered call back. This is non-blocking API.
[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 |
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 |
Returns
Positive Value - Success, returns the number of bytes sent successfully Negative Value - Failure zero - Socket close error
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.
779
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)
This API sends the data to the remote peer on the given socket. This is a non-blocking API.
[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 |
rsi_connect()/ rsi_accept() API needs to be called before this API.
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 |
Returns
Positive Value - Success, returns the number of bytes sent successfully Negative Value - Failure Zero Value - Socket close error
821
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.
[in] | sockID | - Socket descriptor ID |
Returns
Void
847
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.
[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
Zero - Success Negative Value - Failure
875
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)
Callback function used to send one chunk of data at a time.
[in] | sockID | - Socket descriptor ID |
[in] | length | - Length of data to send |
Returns
Void
941
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(*)(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.
[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
Zero - Success, number of bytes sent successfully Negative Value - Failure
1034
of file network/socket/rsi_socket.c
rsi_find_socket_data_pending#
uint32_t rsi_find_socket_data_pending (uint32_t event_map)
Find which socket the data is pending, according to the event that is set from the map.
[in] | event_map | - Event map |
Returns
SockID - Return the SockID from the event map
1120
of file network/socket/rsi_socket.c
rsi_socket_event_handler#
void rsi_socket_event_handler (void )
Retrieve the packet from protocol TX data pending queue and forward to the module.
[in] |
Returns
Void
1143
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(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)
Send data on a given socket asynchronously.
[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 |
rsi_socket()/ rsi_socket_async() API needs to be called before this API.
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 |
Returns
Positive Value - Success, returns the number of bytes sent successfully Negative Value - Failure Zero Value - Socket close error
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.
1190
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.
[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 |
rsi_socket()/ rsi_socket_async() API needs to be called before this API.
Returns
0 - Success Negative Value - Failure
1216
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.
[in] | sock_id | - Module's socket descriptor ID |
Returns
Positive Value - Application index Negative Value - If index is not found
1270
of file network/socket/rsi_socket.c
rsi_clear_sockets#
void rsi_clear_sockets (int32_t sockID)
Clear socket information.
[in] | sockID | - Socket descriptor ID |
Returns
Void
1284
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.
[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
Zero - Success Negative Value - Failure
1303
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.
[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 |
[in] | option_value | - Value of the parameter |
[in] | option_len | - Length of the parameter |
rsi_setsockopt() API needs to be called after rsi_socket command only.
Returns
0 - Success -2 - Invalid parameters -3 - Command given in wrong state -4 - Buffer not available to serve the command
Note
Default window size is 2920 bytes. To modify window size, user need to configure HIGH_PERFORMANCE socket in rsi_setsockopt()
1359
of file network/socket/rsi_socket.c
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.
[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 |
rsi_getsockopt() API needs to be called after rsi_socket command only.
Returns
Zero - Success Negative Value - Failure
1632
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(*)(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)
Select is a BSD API which allow a program to 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.
[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 |
rsi_accept()/ rsi_connect() API's needs to be called before this API.
Note
rsi_select() API needs to be called before rsi_recv()/ rsi_recvfrom()/ rsi_send() API's.
Returns
Zero - Time out Positive Value - Indicate total number of bits ready across all the descriptor sets Negative Value - Failure
Note
Refer to Error Codes section for the description of the above error codes Error Codes.
1720
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.
[in] | type | - Type |
[in] | length | - Length |
Returns
Zero - Success Negative Value - Failure
1960
of file network/socket/rsi_socket.c
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.
[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 if it is IPV4 connection, 6 if it is IPV6 connection |
Returns
Zero - Success Negative Value - Failure
1988
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 available socket pool.
[in] | src_port | - Pointer to the socket source port |
Returns
Positive Value - Application index Negative Value - If index is not found
2154
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)
Function to get the primary socket ID from port number.
[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
2187
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.
[in] | port_num | - Pointer to port number |
Returns
Positive Value - Socket descriptor Negative Value - If socket is not found
2217
of file network/socket/rsi_socket.c
rsi_certificate_valid#
int32_t rsi_certificate_valid (uint16_t valid, uint16_t socket_id)
Host indicate the status to module after validating the server certificate received from module. This is a non-blocking API.
[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
2258
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, 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.
[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
2322
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 primary socket ID based on source port number, destination port number, destination IP address, and the IP version. This is a non-blocking API.
[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
2655
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(*)(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 call. This is a non-blocking API.
[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 |
rsi_config_ipaddress() API needs to be called before this API.
Returns
0 - Success Negative Value - Failure
Note
Refer to Error Codes section for the description of the above error codes Error Codes.
2765
of file network/socket/rsi_socket.c
rsi_socket_connect#
int32_t rsi_socket_connect (int32_t sockID, struct rsi_sockaddr * remoteAddress, int32_t addressLength)
Connect the socket to 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.
[in] | sockID | - Socket descriptor ID |
[in] | remoteAddress | - Remote peer address structure |
[in] | addressLength | - Remote peer address structrue length |
Returns
0 - Success Negative Value - Failure
2950
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.
[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 |
rsi_socket()rsi_socket_async() API needs to be called before this API.
Returns
Value
Description
Positive Value
Number of bytes received successfully
0
Socket close error
Negative Value
Failure
3087
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.
[in] | sockID | - Socket descriptor ID |
[in] | backlog | - Maximum number of pending connections requests |
Returns
0 - Success Negative Value - Failure
3368
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.
[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. |
rsi_socket()/ rsi_socket_async() API needs to be called before this API.
Note
1. 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().
Returns
0 - Success Negative Value - Failure
3469
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.
[in] | sockID | - Socket descriptor ID |
[in] | localAddress | - Address that needs to be assign |
[in] | addressLength | - Length of the socket address |
Returns
0 - Success Negative Value - Failure
3614
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)
Wireless Library to acquire or wait for NWK semaphore.
[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
3769
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 socket descriptor. This is a non-blocking API.
[in] | sock_id | - Module's socket descriptor ID |
Returns
Positive Value - Application index Negative Value - If index is not found
3798
of file network/socket/rsi_socket.c
rsi_wlan_socket_get_status#
int32_t rsi_wlan_socket_get_status (int32_t sockID)
Return WLAN status. This is a non-blocking API.
[in] | sockID | - Application socket ID |
Returns
WLAN status
3833
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.
[in] | status | - Status value to be set |
[in] | sockID | - Application socket ID |
Returns
Void
3847
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.
[in] | selectid | - Socket ID to get the status |
Returns
Zero - Success Negative Value - Failure
3863
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.
[in] | status | - Status value to be set |
[in] | selectid | - Socket ID on which the status is set |
rsi_socket()/ rsi_socket_async() API needs to be called before this API.
Returns
Void
3884
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(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)
Send data on a given socket asynchronously.
[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 |
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 |
Returns
Zero - Success Negative Value - Failure
Note
Refer to Error Codes section for the description of the above error codes Error Codes.
3919
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(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)
Send data to specific remote peer on a given socket.
[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, Returns the number of bytes sent successfully Negative Value - Failure zero - Socket close error
Note
Refer to Error Codes section for the description of the above error codes Error Codes.
4005
of file network/socket/rsi_socket.c
rsi_clear_sockets_non_rom#
void rsi_clear_sockets_non_rom (int32_t sockID)
Clear socket information.
[in] | sockID | - Socket descriptor ID |
Returns
Void
4224
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 socket descriptor. This is a non-blocking API.
[in] | global_cb_p | - Pointer to the global control block |
[in] | sock_id | - Module's socket descriptor |
Returns
Positive value - Application index Negative value - If index is not found
34
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.
[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
64
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.
[in] | global_cb_p | - Pointer to the global control block |
[in] | type | - Type of socket to create |
[in] | length | - Length of the message |
Returns
The number of buffers required for a data packet
93
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)
Caluculate the msg length sent using available buffers. This is a non-blocking API.
[in] | global_cb_p | - Pointer to the global control block |
[in] | type | - Type of the socket stream |
[in] | buffers | - Available buffers |
Returns
Length - Length available in the buffer for msg.
145
of file network/socket/rsi_socket_rom.c
rsi_socket_config#
int32_t rsi_socket_config (void )
Set the socket configuration parameters. Using this command (optional) is highly recommended. Based on the socket configuration, module will use available buffers effectively. This is a blocking API.
N/A |
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
Must be given after IP configuration command and before any socket creation.
Returns
Zero - Success Non-Zero Value - Failure If return value is greater than 0 0x0021,0x0025,0x002C,0xFF6D
Note
Refer to Error Codes section for the description of the above error codes Error Codes.
7199
of file wlan/rsi_wlan_apis.c