From: David Alan Black Date: 2001-03-03T02:26:54+09:00 Subject: [ruby-talk:11909] Re: TCPSocket On Sat, 3 Mar 2001, Alex McHale wrote: > Hi there, > I'm working on the networking core for a client/server, and am just working on > familiarizing myself with the Ruby classes for this. I have a very basic client > that would hopefully connect to a server and just display what it receives. But it > just doesn't work without me sending information. Like this: > > require 'socket' > s = TCPSocket.open( 'localhost', 80 ) > while TRUE > print s.gets > end > > I know it isn't quite proper with the endless loop, but it is only there for testing > purposes. But it just doesn't work. This, however, works, assuming I hit enter > each time I want a line, instead of just displaying everything it receives: > > require 'socket' > s = TCPSocket.open( 'localhost', 80 ) > while gets > s.write $_ > print s.gets > end > s.close Try sending only one line to the server: require 'socket' s = TCPSocket.open( 'localhost', 80 ) s.puts "nonsense" # or something real, if you prefer print s.read David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav