From: GOTO Kentaro Date: 2001-11-07T22:43:01+09:00 Subject: [ruby-talk:24512] Re: TCPServer example in PP book From: Massimiliano Mirra Subject: [ruby-talk:24481] TCPServer example in PP book Date: Wed, 7 Nov 2001 13:16:08 +0900 > require 'socket' > > class TimeServer < TCPServer > def run > while ( session = accept ) > session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n" session.gets("\r\n\r\n") # read request > session.print "

#{Time.now}

\r\n" > session.close > end > end > end > > if $0 == __FILE__ > timeserv = TimeServer.new('localhost', '8082') > timeserv.run > end > > When I connect with e.g. lynx localhost:8082, lynx first results in > "Alert!: Unexpected server disconnect." and then shows expected page > with time and date. The example on the book, of course, works > perfectly and shows in the expected page immediately. Could anyone > point out what am I doing wrong, please? The socket seems to be blocked by unflushed request. I have no idea about platform dependencies. Anyone? -- Gotoken