From: Eric Hodel Date: 2005-07-06T08:49:07+09:00 Subject: Re: Establishing new TCP Socket connection On 05 Jul 2005, at 14:03, Joe Van Dyk wrote: > If I want to establish a new TCP connection every time I need to > access data (the server doesn't want to keep old connetions around), > is there any reason why I can't do something like: > > def send_message_and_recv_response > server = TCPSocket.new @server_ip, @server_port > server.puts "the message" > result = server.recv > end You could be more friendly to the other end by adding an explicit close: def do_the_stuff sock = TCPSocket.new @ip, @port sock.puts "message" return sock.recv ensure sock.close unless sock.nil? end -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04