From: "Jon A. Lambert" Date: 2006-05-06T13:13:11+09:00 Subject: Re: Considering Ruby For a Networking Application James Edward Gray II wrote: > > However, I think I remember someone saying Ruby 1.8.4 is better with > nonblocking sockets. So, can some networking guru take a stab at > these questions: I haven't noticed any difference between 1.8.3 and 1.8.4. > 1. I need to use threads *and* nonblocking sockets to be safe, right? No. The whole point of select() and non-blocking sockets is to de-multiplex I/O. > 2. Can I use gets() and puts() now in Ruby 1.8.4 or do I still need > to do low level reads and writes? I would guess these would be "unsafe" as would any network I/O function that depends on specific separators. Would gets() effectively block on a non-blocking socket if the EOL separator never arrives? *shrug* I don't know. > 3. Do I need to rescue Errno::EWOULDBLOCK? Yes. > 4. This isn't going to work on Windows, right? (That's okay in this > case. Just making sure.) Sure it work on Windows. Here's a pretty good example. No threads. Single select client/server code that uses non-blocking sockets. http://sourcery.dyndns.org/svn/teensymud/release/tmud-2.9.0/lib/network/ -- J. Lambert