From: Robert Klemme Date: 2003-04-23T20:19:16+09:00 Subject: Re: Select() Another option might be to use threads. robert "ts" schrieb im Newsbeitrag news:200304231016.h3NAGcG08797@moulon.inra.fr... > >>>>> "K" == Kuros writes: > > K> I'm very new to Ruby, I generally work in Python. I am wanting to try = > K> writing a simple little chat server in it. The problem is, I'm trying to = > K> find something in ruby similar to the select() function in C/Python that = > K> returns a list of readable/writeable/error sockets, but I can't seem to = > K> find one. > > Kernel::select > > pigeon% ri Kernel::select > --------------------------------------------------------- Kernel::select > select( readArray [, writeArray [errorArray [timeout]]] ) -> > anArray or nil > ------------------------------------------------------------------------ > Performs a low-level select call, which waits for data to become > available from input/output devices. The first three parameters are > arrays of IO objects or nil. The last is a timeout in seconds, > which should be an Integer or a Float. The call waits for data to > become available for any of the IO objects in readArray, for > buffers to have cleared sufficiently to enable writing to any of > the devices in writeArray, or for an error to occur on the devices > in errorArray. If one or more of these conditions are met, the call > returns a three-element array containing arrays of the IO objects > that were ready. Otherwise, if there is no change in status for > timeout seconds, the call returns nil. If all parameters are nil, > the current thread sleeps forever. > select( [$stdin], nil, nil, 1.5 ) #=> [[#], [], []] > > pigeon% > > > Guy Decoux >