7stud has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
It's my understanding that the 'readers': <> and read() are filtered through the C stdio library, and that stdio automatically does:
It's also my understanding that IO::Socket::INET sockets are created with autoflush turned on, which eliminates buffering on those sockets. But what about newline conversions? As far as I can tell, newline conversions aren't affected by autoflush(). So it seems to me that if you want to prevent newline conversions while reading from a socket, you have to either:
However, on p. 119 of "Network Programming with Perl", after the author points out that when reading the message body of an http response, you must be prepared to read binary data, e.g. an mp3 file (where you don't want to do newline conversions), the author uses the following code to read the body of an http response:
print $data while read($socket, $data, 1024) > 0;
where $socket is an IO::Socket::INET socket. Isn't the read() there going to do newline conversions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO::Socket::INET newline conversions and buffering
by almut (Canon) on Feb 21, 2010 at 17:55 UTC | |
|
Re: IO::Socket::INET newline conversions and buffering
by ikegami (Patriarch) on Feb 21, 2010 at 18:17 UTC | |
|
Re: IO::Socket::INET newline conversions and buffering
by 7stud (Deacon) on Feb 23, 2010 at 15:07 UTC |