How to maintain the TCP connection using Ruby?
问题 Using TCPSocket , I need to socket.puts "foobar" , and then socket.close to let the socket in the other side socket.read the message. Is there a way to send or receive a message though a socket, but without closing the socket, which mean I can send message again without creating a socket again? p.s Something like websocket 回答1: If you traverse up the super class chain you will eventually see that you inherit from IO. Most IO objects, in Ruby, buffer the data to be more efficient writing and