From: "David S." Date: 2001-03-07T06:50:47+09:00 Subject: [ruby-talk:12186] Re: Nonblocking Read] On Wed, Mar 07, 2001 at 06:12:55AM +0900, Alex McHale wrote: > This is what I had initially seen - but in my tests, it still *seems* to > be blocking. For example (this is not what will be the end product, this > is a simple conversion of my current code to sysread, dysfunctional as it > is). > > Thread.start do > print "Beginning\n" > while player.connected and (incomm = player.socket.sysread 1) > print "Inside loop\n" > incomm.chop! > player.inbuff= incomm > sleep 0.1 > print "Done with loop\n" > end > print "Ending\n" > end The UNIX call for doing it would be something like fcntl(fd, F_SETFL, O_NONBLOCK) In Ruby you could do player.socket.fcntl(...) but I don't know if Ruby makes the constants 'F_SETFL' or 'O_NONBLOCK' available. You probably need to look the 'fcntl' man page on your system, and the 'fcntl.h' header file. David S. > Thanks, > Alex McHale