[comp.lang.c] "select" and "poll"

guy%gorodish@Sun.COM (Guy Harris) (03/23/87)

(Redirected to comp.unix.wizards; the discussion is no longer about
C.)

>(I understand System VII ... no, make that System V release 3 [cannot
>change a standard! :-) ] for the Vax has something equivalent, but harder
>to use.)

S5R3 for the 3B2 (no more VAX distributions) has "poll", which *only*
works on streams.  This means it will *not* work on terminals, at
least in S5R3.  It is more complicated, but provides more
information.  You pass it an array of structures, one member for file
descriptor to be polled.  Each structure contains:

	1) an "int" specifying the file descriptor number;

	2) a "short" specifying the events to wait for on that
	descriptor;

	3) a "short" specifying which events occurred on that
	descriptor.

The "short"s are bitsets; the possible members of the bitset are:

	POLLIN - ordinary input can be read; a regular message is at
	the stream head.

	POLLPRI - a priority message is at the stream head (POLLIN
	and POLLPRI will not both be set in the second "short").

	POLLOUT - ordinary output can be written; the first write
	queue downstream of the stream head is not full.

	POLLERR - an error message has arrived at the stream head.
	You cannot poll for this; it only appears in the second
	"short".

	POLLHUP - a hangup message has arrived at the stream head
	(this means e.g. that the connection has been broken).  You
	cannot poll for this; it only appears in the second "short".

	POLLNVAL - the file descriptor given is not valid.