From: "Kontra, Gergely" Date: 2002-05-11T03:53:42+09:00 Subject: Re: BUG! Platform independent? sockets and select First, Dossy, thank you for wasting your time with this stuff! >Looking at your code in ServerDisp.rb: > > 36 nsock = select(socks.keys|[@server],nil,nil,10) > 37 if nsock == nil or nsock[0]==nil or nsock[0]==[]# why could >it happen? > 38 puts ":(" > 39 next > 40 end > >The answer to the question on line 37 is that you're specifying >a 10 second timeout. If you don't get a new connection or >no connected client sends you data or disconnects and sends >an eof, after 10 seconds select will return with nsock >being [[], [], []]. But the frequency of the :( printed is not 1 line/10sec, but ~20line/sec!!! Well, when timeout was nil, it happened too. >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. Inside it is checked by line.strip, which wipes out "\r\n" endings. BTW s.eof? before these lines can handle the end of the connection. Gergo +-[Kontra, Gergely @ Budapest University of Technology and Economics]-+ | Email: kgergely@mcl.hu, kgergely@turul.eet.bme.hu | | URL: turul.eet.bme.hu/~kgergely Mobile: (+36 20) 356 9656 | +-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+ . Magyar php mirror es magyar php dokumentacio: http://hu.php.net