XSocket API  2.0
XIA Socket Library
Functions
Xselect.c File Reference

Xselect(), Xpoll() - synchronous I/O multiplexing. More...

#include "Xsocket.h"

Functions

int Xpoll (struct pollfd *ufds, unsigned nfds, int timeout)
 waits for one of a set of Xsockets or file descriptors to become ready to perform I/O. More...
 
int Xselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)
 waits for one of a set of Xsockets to become ready to perform I/O. More...
 

Function Documentation

int Xpoll ( struct pollfd *  ufds,
unsigned  nfds,
int  timeout 
)

Xsocket specific version of poll. See the poll man page for more detailed information. This function is compatible with Xsockets as well as regular sockets and fds. Xsockets are polled via click, and regular sockets and fds are handled through the normal poll API.

Parameters
ufdsarray of pollfds indicating sockets and states to check for
nfdsnumber of entries in ufds
socket ids specified as 0 or negative will be ignored
valid flags for events are POLLIN | POLLOUT | POLLERR
revents contains the returned flags and can be POLLIN | POLLOUT | POLLERR | POLLINVAL | POLLHUP
timeoutnumber of milliseconds to wait for an event to happen
Returns
0 if timeout occured
a positive integer indicating the number of sockets with return events
-1 with errno set if an error occured
int Xselect ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  errorfds,
struct timeval *  timeout 
)

Xsocket specific version of select. See the select man page for more detailed information. This function is compatible with Xsockets as well as regular sockets and fds. Xsockets are handled with the Xpoll APIs via click, and regular sockets and fds are handled through the normal select API.

Parameters
nfdsThe highest socket number contained in the fd_sets plus 1
readfdsfd_set containing sockets to check for readability
writefdsfd_set containing sockets to check for writability
errorfdsfd_set containing sockets to check for errors
timeoutamount of time to wait for a socket to change state
Returns
greater than 0, number of sockets ready
0 if the timeout expired
less than 0 if an error occurs
Warning
this function is only valid for stream and datagram sockets.