06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

select pNA+ <strong>System</strong> <strong>Calls</strong><br />

select Checks the status of multiple sockets.<br />

#include <br />

long select(<br />

int width, /* largest descriptor list */<br />

fd_set *readset, /* read descriptor list */<br />

fd_set *writeset, /* write descriptor list<br />

fd_set *exceptset, /* exception list */<br />

struct timeval *timeout /* timeout for operation */<br />

)<br />

Description<br />

Arguments<br />

This system call is used to multiplex I/O requests among multiple sockets. Three<br />

sets of socket descriptors may be specified: a set of sockets from which to read, a set<br />

to which to write and a set that may have pending exceptional conditions.<br />

Each set is actually a structure containing an array of long integer bit masks. The<br />

size of the array is set by the definition of FD_SETSIZE (in .) The array is<br />

long enough to hold one bit for each FD_SETSIZE socket descriptor.<br />

If select() returns successfully, the three sets indicate which socket descriptors<br />

can be read, which can be written to, or which have exceptional conditions pending.<br />

A timeout value may be specified.<br />

width Specifies the largest descriptor list given by readset, writeset,<br />

or exceptset.<br />

readset Points to a set of sockets from which to read.<br />

writeset Points to a set of sockets to which to write.<br />

exceptset Points to a set of sockets that may have an exceptional condition<br />

pending.<br />

4-54 <strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!