Select API#

Modules#

fd_set

Typedefs#

typedef long int

A type representing a set of file descriptors.

Functions#

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.

void

Check the read socket file descriptor set.

void

Check the write socket file descriptor set.

void

Initialize the select system.

Macros#

#define
FD_CLR (d, set)

Clear the bit for the file descriptor d in the fd_set.

#define
FD_ELT (d)

Calculate the index in the fds_bits array for the file descriptor d.

#define
FD_ISSET (d, set)

Check whether the bit for the file descriptor d is set in the fd_set.

#define

Create a mask for the bit position within an fd_mask for the file descriptor d.

#define
FD_SET (d, set)

Set the bit for the file descriptor d in the fd_set.

#define

Maximum number of file descriptors in ‘fd_set’.

#define
FD_ZERO (set)

Clear all bits in the fd_set.

#define
NFDBITS (8 * (int) sizeof (fd_mask))

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.


Definition at line 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.

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


Definition at line 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.

Parameters
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...
}

Definition at line 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.

Parameters
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...
}

Definition at line 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.

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


Definition at line 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_CLR
Value:
(d, set)

Clear the bit for the file descriptor d in the fd_set.


Definition at line 102 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h

FD_ELT#

#define FD_ELT
Value:
(d)

Calculate the index in the fds_bits array for the file descriptor d.

Returns

  • The index in the fds_bits array.


Definition at line 86 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h

FD_ISSET#

#define FD_ISSET
Value:
(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.


Definition at line 126 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h

FD_MASK#

#define FD_MASK
Value:
(d)

Create a mask for the bit position within an fd_mask for the file descriptor d.

Returns

  • The mask for the bit position.


Definition at line 94 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h

FD_SET#

#define FD_SET
Value:
(d, set)

Set the bit for the file descriptor d in the fd_set.


Definition at line 110 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h

FD_SETSIZE#

#define FD_SETSIZE
Value:
64

Maximum number of file descriptors in ‘fd_set’.


Definition at line 67 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h

FD_ZERO#

#define FD_ZERO
Value:
(set)

Clear all bits in the fd_set.


Definition at line 117 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h

NFDBITS#

#define NFDBITS
Value:
(8 * (int) sizeof (fd_mask))

The number of bits in an fd_mask.


Definition at line 64 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/protocol/wisun/stack/inc/socket/select.h