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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.