From: Dmitri Kondratiev Date: 2006-09-24T02:46:26+09:00 Subject: Re: XP: "An existing connection was forcibly closed" ECONNRE Mike, This doesn't help. Before, eventually looking into the source of gserver.rb I tried my code on Debian Linux - same error. Which is good, at least Ruby is consistent accross platforms. If you look at gserver.rb you will see that this server closes client socket right after it servers it, which he must not do and which perfectly explains why gserver.rb does not work correctly. Also see my coments (#dk:) inline: > Dima, > > You're connecting to the server using HTTP, so the server should > return valid HTTP header, i.e.: > > class TimeServer < GServer > def initialize(port=10001, *args) > super(port, *args) > end > def serve(io) > str = "HTTP/1.0 200 OK\r\n\r\n#{Time.now.to_i}" > puts str ~~~~~~~~ #dk: This may confuse: server itself outputs its own response > io.puts(str) > end > end > > Haven't tried it on Windows, but this works on Mac whereas your > version fails as you described. > gserver.rb closes client socket right after serving it :( From gserver.rb: client = @tcpServer.accept @connections << Thread.new(client) { |myClient| begin myPort = myClient.peeraddr[1] serve(myClient) if !@audit or connecting(myClient) rescue => detail error(detail) if @debug ensure begin myClient.close rescue end @connectionsMutex.synchronize { @connections.delete(Thread.current) @connectionsCV.signal } disconnecting(myPort) if @audit end } end Dima -- Posted via http://www.ruby-forum.com/.