I'm using Ruby 1.8.4 on Linux and I'm having trouble with non-blocking
sockets. Socket#accept_nonblock doesn't exist and using fcntl to set
O_NONBLOCK before calling accept doesn't seem to work. I've tried with
TCPServer and Socket and accept blocks in both cases. What's the 1.8.4
way to get non-blocking sockets?

Some sample code:

p = 8080
socket = Socket.new Socket::AF_INET, Socket::SOCK_STREAM, 0
sock_addr = Socket.pack_sockaddr_in p, '0.0.0.0'
socket.bind sock_addr
socket.listen SERVER_QUEUE_LENGTH
original_flags = socket.fcntl Fcntl::F_GETFL, 0
socket.fcntl(Fcntl::F_SETFL, original_flags | Fcntl::O_NONBLOCK)
connection = socket.accept

I first tried nearly the same thing, but used a TCPServer instead of a
Socket and called fcntl as above before calling accept. In both
examples, the accept call blocks.

I'm new to socket programming so I'm probably just missing something.
Any ideas? Maybe I'll just upgrade to 1.8.6.

Thanks,
Jeremy