KallistiOS  2.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Typedefs | Functions
poll.h File Reference

Definitions for the poll() function. More...

#include <sys/cdefs.h>
#include <sys/types.h>

Go to the source code of this file.

Data Structures

struct  pollfd
 Structure representing a single file descriptor used by poll(). More...


#define POLLRDNORM   (1 << 0)
 Normal data may be read.
#define POLLRDBAND   (1 << 1)
 Priority data may be read.
#define POLLPRI   (1 << 2)
 High-priority data may be read.
#define POLLOUT   (1 << 3)
 Normal data may be written.
 Normal data may be written.
#define POLLWRBAND   (1 << 4)
 Priority data may be written.
#define POLLERR   (1 << 5)
 Error has occurred (revents only)
#define POLLHUP   (1 << 6)
 Peer disconnected (revents only)
#define POLLNVAL   (1 << 7)
 Invalid fd (revents only)
 Data other than high-priority data may be read.


typedef __uint32_t nfds_t
 Type representing a number of file descriptors.


int poll (struct pollfd fds[], nfds_t nfds, int timeout)
 Poll a group of file descriptors for activity.

Detailed Description

Definitions for the poll() function.

This file contains the definitions needed for using the poll() function, as directed by the POSIX 2008 standard (aka The Open Group Base Specifications Issue 7). Currently the functionality defined herein only works for sockets, and that is likely how it will stay for some time.

The poll() function works quite similarly to the select() function that it is quite likely that you'd be more familiar with.

Lawrence Sebald

Typedef Documentation

typedef __uint32_t nfds_t

Type representing a number of file descriptors.

Function Documentation

int poll ( struct pollfd  fds[],
nfds_t  nfds,
int  timeout 

Poll a group of file descriptors for activity.

This function will poll a group of file descriptors to check for the events specified on them. The function shall block for the specified period of time (in milliseconds) waiting for an event to occur. The function shall return as soon as at least one fd matches the events specified (or one of the error conditions), or when timeout expires.

fdsThe file descriptors to check, and what events to look for on each.
nfdsNumber of elements in fds.
timeoutMaximum amount of time to block, in milliseconds. Pass 0 to ensure the function does not block and -1 to block for an "infinite" amount of time, until an event occurs.
-1 on error (sets errno as appropriate), or the number of file descriptors that matched the event flags before the function returns.
See also:
Events for the poll() function