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#
Calculate the index in the fds_bits array for the file descriptor d.
Create a mask for the bit position within an fd_mask for the file descriptor d.
Maximum number of file descriptors in ‘fd_set’.
The number of bits in an fd_mask.
Typedef Documentation#
fd_mask#
typedef long int fd_mask
A type representing a set of file descriptors.
70
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
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.
[in] | nfds | The highest-numbered file descriptor in any of the three sets, plus 1. |
[inout] | readfds | An optional pointer to a set of file descriptors to be checked for readability. |
[inout] | writefds | An optional pointer to a set of file descriptors to be checked for writability. |
[inout] | exceptfds | An optional pointer to a set of file descriptors to be checked for exceptions. |
[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.
150
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
sl_wisun_check_read_sockfd_set#
void sl_wisun_check_read_sockfd_set (void )
Check the read socket file descriptor set.
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...
}
72
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/sl_select_util.h
sl_wisun_check_write_sockfd_set#
void sl_wisun_check_write_sockfd_set (void )
Check the write socket file descriptor set.
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...
}
97
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/sl_select_util.h
sl_wisun_select_init#
void sl_wisun_select_init (void )
Initialize the select system.
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.
46
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/sl_select_util.h
Macro Definition Documentation#
FD_CLR#
#define FD_CLRValue:
(d, set)
Clear the bit for the file descriptor d in the fd_set.
102
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
FD_ELT#
#define FD_ELTValue:
(d)
Calculate the index in the fds_bits array for the file descriptor d.
Returns
The index in the fds_bits array.
86
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
FD_ISSET#
#define FD_ISSETValue:
(d, set)
Check whether the bit for the file descriptor d is set in the fd_set.
Returns
Nonzero if the bit is set, and zero otherwise.
126
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
FD_MASK#
#define FD_MASKValue:
(d)
Create a mask for the bit position within an fd_mask for the file descriptor d.
Returns
The mask for the bit position.
94
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
FD_SET#
#define FD_SETValue:
(d, set)
Set the bit for the file descriptor d in the fd_set.
110
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
FD_SETSIZE#
#define FD_SETSIZEValue:
64
Maximum number of file descriptors in ‘fd_set’.
67
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
FD_ZERO#
#define FD_ZEROValue:
(set)
Clear all bits in the fd_set.
117
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h
NFDBITS#
#define NFDBITSValue:
(8 * (int) sizeof (fd_mask))
The number of bits in an fd_mask.
64
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h