From: Brian Candler Date: 2005-07-17T19:41:17+09:00 Subject: Re: Nonblocking Sockets On Sun, Jul 17, 2005 at 07:01:54AM +0900, Bill Kelly wrote: > From: "James Edward Gray II" > > > > Is this the "standard" way to make a nonblocking Socket in Ruby? > > > > require "socket" > > require "fcntl" > > > > server = TCPServer.new(...) > > server.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK) > > > > __END__ > > > > Will that work on Unix and Windows? > > As far as I know it's the "standard" way (but that > just means it's the only way I know of. :) > > It doesn't work on Windows. :( > > I've ended up tacking on: ... if defined? Fcntl::O_NONBLOCK > onto the fcntl() line so that my scripts still run on > windows, even though they may block inappropriately. > > Blocking I/O issues have been a thorny issue for me in > trying to write cross-platform network applications in > Ruby. Aside: would it be appropriate to use Ruby threads in your application? It can hide a lot of socket blocking nastiness. And I presume the interpreter copes with Windows. Regards, Brian.