From: Dossy Date: 2002-05-11T05:06:23+09:00 Subject: Re: BUG! Platform independent? sockets and select On 2002.05.10, Kontra, Gergely wrote: > First, Dossy, thank you for wasting your time with this stuff! My pleasure. > But the frequency of the :( printed is not 1 line/10sec, but > ~20line/sec!!! > > Well, when timeout was nil, it happened too. Very strange. Every time select() returns, can you change 38 puts ":(" to 38 puts ":( #{nsock.inspect}" and see if that reveals anything interesting? > >I think the problem under Win32 is that line endings are not > >\n like they are in Unix/Linux, but \r\n. So: > > > > 52 else # just another line > > 53 if socks[s].processLine(s.gets)==false > > 54 socks.delete(s) > > 55 puts("#{s} is gone") > > 56 end > > > >Replace s.gets with s.gets.chop, see if that makes a > >difference. > > I cannot see any difference. processLine will return false, only if it > doesn't respond well to the server's greeting. I would suggest not only deleting the socket from the Hash, but closing it too. Just because the client might have disconnected doesn't actually close the socket (filehandle) on the server, you should always close it too. Insert "s.close" before line 54. > Inside it is checked by line.strip, which wipes out "\r\n" endings. Ah, that's true. Okay ... > BTW s.eof? before these lines can handle the end of the connection. That's true. Maybe you don't _need_ to insert "s.close" before line 54. Hmm. Running the server on Win32, have you tried testing it by hand (connect via telnet client, send appropriate strings by hand) and see if it the server works? -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)