Basically all system calls return 0 or positive numbers when they succeed, and negative values are returned when they fail.
Advanced Operations for Streams
Poll system call format
#include <stropts.h>
#include <poll>
Int poll (fds,nfds,timeout)
struct POLLFD fds[]; /* Flow Group Description Structure * *
unsigned long Nfds; /* Flow Number * *
int timeout; /* Query Timeout/*
Parameter and Function Description:
The parameter Nfds indicates the number of streams in the stream group, while the FDS is a flow group description structure, and his format is as follows:
struct POLLFD
{
int FD; /* Flow Descriptor/*
Short http://www.aliyun.com/zixun/aggregation/38907.html ">events; * * User Expected Event/
Short revents; /* Events occurring on the stream/*
}FDS[NFDS];
The function is to query whether a user expects events occur on each stream in the flow group. If an event occurs, the event that occurs is registered in the revents domain of the flow group description structure and returned to the user. If no event occurs, sleep waits until an event occurs or waits for a timeout. The timeout period has a parameter timeout given, in milliseconds. When timeout is-1, the timeout value is infinite and can wait indefinitely.
There are three types of events that users expect, and their values and meanings are as follows:
POLLIN: Expect a data message to be reached on the corresponding stream.
Pollout: Expect to be able to send a data message to the corresponding stream.
POLLPRI: Expect a high priority data message to be reached on the corresponding stream (high priority is a control message)
There are three kinds of revents values: 0, events that have occurred, error events.
0 indicates that no expected event occurred on the corresponding stream. An event that has occurred is the event expected by the stream, and an error event is the value set when the poll call fails, and he can have three values, which may be "or" for the three values in the revents. The value of the error event and its meaning are as follows:
Pollerr: An error message is reached on the stream, and the operation of the convection cannot continue.
Pollhup: A suspend condition appears on the stream, and then the message cannot be sent convection.
Pollnval: illegal flow descriptor.