O'Reilly logo

Advanced UNIX Programming by Warren W. Gay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

I/O Polling

The function poll(2) represents another way to perform efficient I/O scheduling. It was originally developed by AT&T to be used for STREAMS file descriptors. However, poll(2) now accepts all file descriptors. The function synopsis for poll(2) is as follows:

/*
 * UnixWare 7, SGI IRIX 6.5 :
 */
#include <stropts.h>
#include <poll.h>

/*
 * HP-UX 11.x, Solaris 8 :
 */
#include <poll.h>

/*
 * IBM AIX 4.3 :
 */
#include <sys/poll.h>
#include <sys/select.h>
#include <sys/types.h>

/*
 * FreeBSD :
 */
#include <sys/types.h>
#include <poll.h>

int poll(struct pollfd *fds, unsigned int nfds, int timeout);
struct pollfd {
    int    fd;        /* file descriptor */
    short  events;    /* events to look for */
    short  revents;   /* returned events */
} ;

As you can see, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required