ESOK_getFdSet

- get file descriptors in use by ESOK

SYNOPSIS

#include <$OV_HEADER/ecs/ESOK/sockstack.h>
int32 ESOK_getFdSet
(
	ESOK_FdMaskType fdmaskType,
	int32 *nfds,
	const fd_set **fdset
);

DESCRIPTION

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.

Parameters

ESOK_FdMaskType fdmaskType
The type of mask to return - read, write or exception.

Possible values for anESOK_FdMaskType are as follows:

ESOK_ALLMASKS
All masks (bitwise OR).
ESOK_READMASK
Read mask only.
ESOK_WRITEMASK
Write mask only.
ESOK_EXCEPTIONMASK
Exception mask only.
int32 *nfds
A pointer to an int32 that will contain the number of file descriptors in the returned 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
The file descriptor set. This function returns a pointer to the ESOK internal fd_set requested. This memory is static and you should make a copy of the fdset if you want to keep it.

EXAMPLE

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);

RETURNS

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
Bad parameter.
ESOK_NOT_INITIALISED
ESOK_stackInit has not been called.