From: Vince Forgetta Date: 2008-04-16T22:41:56+09:00 Subject: Re: create server ------=_Part_10359_14245682.1208353314380 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Solved my problem. Used select instead of threads to implement the server. Got the code from "The Ruby Programming Language". What a great book! Vince On Mon, Apr 14, 2008 at 2:54 PM, Vince Forgetta wrote: > Sorry, here is the code: > > require 'gserver' > class HelloServer < GServer > def serve(io) > line = io.gets > io.puts("#{line.chomp}") > end > end > server = HelloServer.new(1234, '127.0.0.1', 1) > server.audit = true > server.start > server.join > > On Mon, Apr 14, 2008 at 2:46 PM, hemant kumar wrote: > > > > > On Tue, 2008-04-15 at 03:16 +0900, Vince Forgetta wrote: > > > Figured it out. > > > > > > I need to sleep between successive calls to TCPSocket.new (see simple > > > example below): > > > > > > require 'socket' > > > for i in 0..20 > > > session = TCPSocket.new('localhost', '1234') > > > session.puts "test" > > > dat = session.gets > > > p dat > > > session.close > > > sleep 0.5 > > > end > > > > > > Using 'sleep 0' cause the server to hang. Is there a way around this? > > > > > > > Perhaps then you should paste server code, rather than client code. > > > > > > > > > ------=_Part_10359_14245682.1208353314380--