Oddities with select

I replied to this a moment ago, and then did the ad hoc experiment
that I should have done before opening my virtual mouth earlier -
sorry 'bout that.

No worries, sorry for implying you might be trolling. I thought that my earlier example made it clear how the 'if' statement in Ruby works, but I guess the truth table was even more clear.

I tested this:

require "socket"

svr = TCPServer.new("localhost", 4567)
sock = svr.accept
printf "Accepted conn\n"
while true
  if select([sock], , , 3.0)
    printf("%s\n", sock.recv(256))
  end
end

I sent some "hello world" messages to it from a TCPSocket. It works
perfectly.

Sorry to appear tardy, tedious or trollish; but what gives?

My question exactly. For me, it works -- *most* of the time. But sometimes, especially when I send it only a single newline, that newline just isn't seen. Select returns nil, but ethereal shows that a packet has arrived. Hence my original question -- why isn't select() seeing that newline.

I guess the correct thing to do is rewrite the thing in C and see if it's a problem in the OS or if it's a problem in Ruby.

Ben

···

On Jun 12, 2004, at 23:23, Chris Reay wrote: