in reply to Remove extra carriage return (0D) on socket communications

I'm not sure that what you have is a Windows vs Unix problem. Standard network termination is 0D0A (like how a Windows box likes to do). So even if 2 Unix boxes were talking in a text mode over a socket, the data over the socket would be CRLF terminated instead of the normal LF like to a terminal/local file. So, on the Unix box, print() does different things depending upon whether it is talking to a network connection or a local file on a Unix box.

I think you are going to wind up using read() and write() instead of print() if you want absolute control of exactly what is sent over the socket. In that case, you would be taking on the job of figuring out what a "line" is.

  • Comment on Re: Remove extra carriage return (0D) on socket communications

Replies are listed 'Best First'.
Re^2: Remove extra carriage return (0D) on socket communications
by BrowserUk (Patriarch) on Nov 12, 2011 at 01:01 UTC
    I'm not sure that what you have is a Windows vs Unix problem.

    Agreed.

    But the simplest solution would probably be to use the :crlf IO layer on the socket handle(s). Then print and readline should do the right thing, just as they do for the windows filesystem.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.