Network protocols aren't text files so you should always use binmode. binmode isn't going to break anything but it might fix some things besides \r\n changes. For example, without binmode under Win32, CTRL-Z would signify end of file.
That is why Perl's socket code under Win32 has: #define OPEN_SOCKET(x) win32_open_osfhandle(x,O_RDWR|O_BINARY) so that Perl sockets under Win32 are always in binmode. This makes me wonder if there are any platforms where binmode is needed but Perl sockets aren't binmode by default.
You make a good point about not using \r and \n when doing network programming. CGI.pm makes a good point about not using \015 when on a EBCDIC machine, which means that Socket.pm is in need of a patch!
And is IO::Socket a replacement for Socket.pm or vice versa or are they just two similar choices?
This sounds like something worth making a tiny module out of and getting CGI.pm, Socket.pm, and IO::Socket to use. (Note that the VMS-specific code in CGI.pm should stay in CGI.pm as that has to do with a quirk of the most popular VMS web server that doesn't follow the spec as opposed to how \r and \n get interpretted under VMS).
- tye (but my friends call me "Tye")In reply to (tye)Re: binmode, CR, LF
by tye
in thread binmode, CR, LF
by bwana147
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |