Ben Giddings <bg-rubytalk / infofiend.com> writes: > I'm trying to use Ruby to talk to an network application, and noticed > something odd. Using ethereal, I can see that the server is returning a > newline to the client, however my Ruby code, calling select([socket], > [], [], 0.1) repeatedly for 5 seconds never seems to know that there's > data to be read. This works for me, unless I am misunderstanding what you are trying to do: ---- test_server.rb ------ #!/usr/bin/ruby -w require 'socket' a = TCPServer.new("localhost", 9999).accept loop do a.puts sleep 3 end -------------------------- and then ---- test_client.rb ------ #!/usr/bin/ruby -w require 'socket' a = TCPSocket.new("localhost", 9999) loop do if select([a], [], [], 0.1) p a.read(1) end end -------------------------- Having already started the server, the client prints out a "\n" as soon as it is started, and then every 3 seconds thereafter. Is it possible that your code is actually getting held up somewhere else, so that it's not even hitting the select()? For example, if I were to change the "a.read(1)" in the client there to just "a.read", then it would get stuck there until the socket was closed.