Hello,
I've just started using ruby. I'm currently using sockets but I've run into
a problem that I can't understand. On the client side I have something like
sock = TCPSocket.new(...)
sock.send("blah\nblah\n\C-D")
Then, on the server side I have
server = TCPServer.new(...)
sock = server.accept
recv_msg = sock.readlines
print recv_msg
But that doesn't work. It just sits there waiting. But if I subsitute the
last two statements with the following, I get the desired results:
while (recv_msg = sock.gets)
print recv_msg
I'm not an experienced socket programmer, so can someone explain to me why I
can't use readlines? Something with blocking? Any help would be greatly
appreciated and apologies in advance if this has been asked before.
Thanks,
Norman Su