From: Child Date: 2002-12-19T20:35:38+09:00 Subject: Re: Socket problem On Thu, 19 Dec 2002 14:25:26 +0900, nobu.nokada@softhome.net wrote: > response = socket.gets > if response.has_text? > while s = socket.gets(".\r\n") > response << s > break if /^\.\r\n\z/ =~ s > end > end It is exactly the way I do it at the moment - very slow (speed is very important when fetching a lot of headers/bodies) >> 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") ? This one should be good. Thank you for all your answers. Speed is essential to me only when fetching headers (and I think I can expect no empty headers), so I can use the "gets ("\r\n.\r\n")" form. I made some tests and the profiler shows (in a simple example - fetching all articles in group) that the time used by the fetching method is now about 10-15% instead of 40-50% :). So I think I'll use one "gets ..." when fetching headers, and ungetc/loop/whatever in other cases. Thanks once again! -- Marek Janukowicz