Select API#
Modules#
Functions#
Monitor multiple file descriptors for readiness.
Check the read socket file descriptor set.
Check the write socket file descriptor set.
Initialize the select system.
Macros#
Clear the bit for the file descriptor d in the fd_set.
Calculate the index in the fds_bits array for the file descriptor d.
Check whether the bit for the file descriptor d is set in the fd_set.
Create a mask for the bit position within an fd_mask for the file descriptor d.
Set the bit for the file descriptor d in the fd_set.
Maximum number of file descriptors in ‘fd_set’.
Clear all bits in the fd_set.
The number of bits in an fd_mask.
Typedef Documentation#
Function Documentation#
select#
int select (int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict exceptfds, struct timeval *restrict timeout)
Monitor multiple file descriptors for readiness.
Type | Direction | Argument Name | Description |
---|---|---|---|
int | [in] | nfds | The highest-numbered file descriptor in any of the three sets, plus 1. |
fd_set *restrict | [inout] | readfds | An optional pointer to a set of file descriptors to be checked for readability. |
fd_set *restrict | [inout] | writefds | An optional pointer to a set of file descriptors to be checked for writability. |
fd_set *restrict | [inout] | exceptfds | An optional pointer to a set of file descriptors to be checked for exceptions. |
struct timeval *restrict | [in] | timeout | An optional timeout. If NULL, select() blocks indefinitely. To specify a non-blocking poll, set the timeout to zero. |
Returns
On success, returns the total number of bits set in readfds, writefds. If the time limit expires, select() returns zero. On error, -1 is returned, and errno is set appropriately.
This function monitors multiple file descriptors, waiting until one or more of the file descriptors are ready for an I/O operation.
Note
This implementation does not handle exceptfds.
sl_wisun_check_read_sockfd_set#
void sl_wisun_check_read_sockfd_set (void )
Check the read socket file descriptor set.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function notifies select to check the read socket file descriptor set. The function should be called in response to the reception of SL_WISUN_MSG_SOCKET_DATA_AVAILABLE_IND_ID. It notifies select to check the read socket file descriptor set for any ready socket to read.
Usage:
// Application indication handler
void sl_wisun_on_event(void) {
// Application code here...
switch (evt->header.id) {
// When SL_WISUN_MSG_SOCKET_DATA_AVAILABLE_IND_ID is received
case SL_WISUN_MSG_SOCKET_DATA_AVAILABLE_IND_ID:
// Call the function to check the read socket file descriptor set
sl_wisun_check_read_sockfd_set();
break;
}
// Application code here...
}
sl_wisun_check_write_sockfd_set#
void sl_wisun_check_write_sockfd_set (void )
Check the write socket file descriptor set.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function notifies select to check the write socket file descriptor set. The function should be called in response to the reception of SL_WISUN_MSG_SOCKET_DATA_SENT_IND_ID. It notifies select to check the write socket file descriptor set for any ready socket to write.
Usage:
void sl_wisun_on_event(void) {
// Your code here...
switch (evt->header.id) {
// When SL_WISUN_MSG_SOCKET_DATA_SENT_IND_ID is received
case SL_WISUN_MSG_SOCKET_DATA_SENT_IND_ID:
// Call the function to check the write socket file descriptor set
sl_wisun_check_write_sockfd_set();
break;
}
// Your code here...
}
sl_wisun_select_init#
void sl_wisun_select_init (void )
Initialize the select system.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function initializes the select system by creating a new event flag with the specified attributes. The event flag is used to indicate when a file descriptor set is ready to be checked for I/O operations.