Eric Hodel wrote:

> $ ruby -rsocket -e 'sv = TCPServer.new nil, 4000; so = sv.accept;
> while data = so.read(10) do p :read => data end'
> {:read=>"0123456789"}
> {:read=>"\r\n234567\r\n"}
> $
> 


Thanks for the help. I used your structure (while data = socket.read) as 
follows in my client app (after opening the in_socket to the server):

messageCount = 0
while data = in_socket.recv( 100 )
  if data.size > 0
    messageCount += 1
    puts "Received message #{messageCount}: #{data}"
  else
    puts "empty"
  end
end

I put in the check for empty messages because I am seeing some odd 
behaviour.
 Basically I can send a certain message to this client no problems 
(message 1 to 4 below), but as soon as message 5 is received the program 
hangs for 15 secs then goes into a mad loop of empty messages:


Received message 1: MESSAGET 18
1234 162 999 9999
Received message 2: MESSAGET 18
1234 162 999 9999
Received message 3: MESSAGET 18
1234 162 999 9999
Received message 4: MESSAGET 18
1234 162 999 9999
Received message 5: MESSAGET 35
0 162 9 0 "&" 82 -1000 2 9 25 "0"
empty
empty
empty
...


Something in that particular received message is making it go bonkers. 
Any ideas?
-- 
Posted via http://www.ruby-forum.com/.