From: nobu.nokada@... Date: 2002-12-19T14:25:26+09:00 Subject: Re: Socket problem Hi, At Thu, 19 Dec 2002 14:04:14 +0900, > > Hmm, then read the status response at first, and read the text > > response if present, according to the protocol. > > I expected following case. > > C> list active comp.lang.r* > S> 215 Newsgroups in form "group high low flags". > S> comp.lang.rexx 0000037710 0000037671 y > S> . > C> list active comp.lang.ru* > S> 215 Newsgroups in form "group high low flags". > S> . > > (Note that comp.lang.ruby is not exist in our news server.) > > The client reads text response after status line. > The status line is "215 ... .\r\n". > > So, socket.gets("\r\n.\r\n") works on "list active comp.lang.r*" but > not on "list active comp.lang.ru*". Because the text response with > terminator is only ".\r\n" which is not terminated by "\r\n.\r\n". Sorry, misunderstood. response = socket.gets if response.has_text? while s = socket.gets(".\r\n") response << s break if /^\.\r\n\z/ =~ s end end > > Fetching available data is possible with io/wait extension > > library, but I don't guess it's reliable to determin the end of > > input. > > I think ungetc can solve the problem by unget "\r\n" before reading > a text response. But stdio doesn't support more than one byte with > ungetc. ungetc(?\n) and gets("\n.\r\n") ? -- Nobu Nakada