Help for this page

Select Code to Download


  1. or download this
    print SOCKET "Hi there, client!\015\012";  # right
    print SOCKET "Hi there, client!\r\n";      # wrong
    
  2. or download this
    use Socket qw(:DEFAULT :crlf);
    print SOCKET "Hi there, client!$CRLF"      # right
    
  3. or download this
    use Socket qw(:DEFAULT :crlf);
    local ($/) = LF;     # not needed if $/ is already \012
    ...
    while (<SOCKET>) {
        s/$CR?$LF/\n/;   # replace LF or CRLF with logical newline
    }