Re: select

Jaap Vermeulen (jaap@sequent.com)
Sun, 28 Jun 92 13:58:57 PDT

| Has anyone created a select function similar to the select in BSD sockets?
|
| I figured you could pass a list of items in and have it return
| a 3 element tupple of the return values..

Not yet, but I was thinking more in the direction of the poll() SYSV
system call. It provides nicer semantics than the bitmask directed
select().

It would look like:

file1 = open ('...', 'r')
file2 = open ('...', 'r')
timeout = 0

filelist = select (((file1, 'r'), (file2, 'r')), timeout)

The input would be a list of (fileobject, string) pairs. The string
would indicate 'r', 'w', 'e', or any permutation of those letters (for
read, write and exception; if you really want to confuse people you
could change the 'e' into an 'x' :-) :-). The timeout would be in some
convenient timeformat with enough granularity to satisfy most needs
(tenth of seconds?). If the timeout is 'None' the call would be
blocking. It will return a list of (fileobject, string) pairs for
those fileobjects that have one or multiple events pending, or 'None'
if there are no pending events on any of the fileobjects.

If you have poll(), the implementation is quite straight-forward. If
you only have select(), you have to construct the bitmasks from the
filelist information (which shouldn't be too hard).

Just my $0.02 worth. Good luck,

-Jaap-

--
Jaap Vermeulen					+--------------------------+
						| Sequent Computer Systems |
	Internet : jaap@sequent.com		| Beaverton, Oregon	   |
	Uucp	 : ...uunet!sequent!jaap	+--------------------------+