- get file descriptors in use by ESOK
#include <$OV_HEADER/ecs/ESOK/sockstack.h> int32 ESOK_getFdSet ( ESOK_FdMaskType fdmaskType, int32 *nfds, const fd_set **fdset );
This function gets a file descriptor set containing the file descriptor numbers for all open connections of the requested type in the socket stack. This fd_set is suitable for passing to select(2). The fd_set can change so this function should be called prior to each use of the file descriptor set in a select(2) call.
ESOK_FdMaskType fdmaskType
Possible values for anESOK_FdMaskType are as follows:
ESOK_ALLMASKS
ESOK_READMASK
ESOK_WRITEMASK
ESOK_EXCEPTIONMASK
int32 *nfds
fd_set. This value should be used to limit the scope of the select call (see select(2) for more details).
const fd_set **fdset
fd_set requested. This memory is static and you should make a copy of the fdset if you want to keep it.
This example retrieves the file descriptor sets from the socket stack to use in a local select(2) call. Error checking has been omitted for clarity.
int32 nbits; int32 nfds; int32 msize; fd_set readFds; fd_set writeFds; fd_set exceptFds; const fd_set* fds;/* get file descriptors in use by ECS engine */
msize = ESOK_getFdSet(ESOK_READMASK, &nfds, &fds); memcpy(&readFds, fds, msize); msize = ESOK_getFdSet(ESOK_WRITEMASK, &nfds, &fds); memcpy(&writeFds, fds, msize); msize = ESOK_getFdSet(ESOK_EXCEPTIONMASK, &nfds, &fds); memcpy(&exceptFds, fds, msize);
errno = 0; nbits = select(nfds, &readFds, &writeFds, &exceptFds, 0);
A value > 0 is the size in bytes of the returned fd_set. Can be used by memcpy(3) size member to copy the returned fd_set.
ECS_BAD_PARAMETER
ESOK_NOT_INITIALISED
ESOK_stackInit has not been called.