KallistiOS  ##version##
 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...
 

Macros

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

Typedefs

typedef __uint32_t nfds_t
 Type representing a number of file descriptors. More...
 

Functions

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

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.

Author
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.

Parameters
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.
Returns
-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