Carriage Returns and sockets - Perl

This is a discussion on Carriage Returns and sockets - Perl ; Hi, I'm using ActivePerl on Win98 and this is starting to annoy me. Why isn't \n accepted as a carriage return when I'm using sockets? If I run the following program, I get no response other than the SMTP info ...

+ Reply to Thread
Results 1 to 2 of 2

Carriage Returns and sockets

  1. Default Carriage Returns and sockets

    Hi, I'm using ActivePerl on Win98 and this is starting to annoy me.
    Why isn't \n accepted as a carriage return when I'm using sockets?
    If I run the following program, I get no response other than the SMTP info
    header. Using a proxy to investigate, I found that what is getting sent to
    the server is only an 0a character not an 0d0a sequence, any help on this
    would be great appreciated. I've already tried sending \r\n and that makes
    no difference.

    #!/usr/bin/perl -w
    use IO::Socket;
    $remote = IO::Socket::INET->new(
    Proto => "tcp",
    PeerAddr => "smtp_host",
    PeerPort => "25",
    )
    or die "cannot connect to server";
    # get SMTP server welcome
    $line=<$remote>;
    print "$line\n";

    # send HELO
    print $remote "HELO\n"; # the \n here doesn't seem to work

    # get reply
    $line=<$remote>;
    print "$line\n";



  2. Default Re: Carriage Returns and sockets

    Just found out the solution:
    $EOL = "\015\012";
    print $remote "HELO".$EOL;

    but does anybody know any easier way?

    "Iceberg" <big_bad_iceberg@tenretnitb.moc> wrote in message
    news:T8o6b.2420$H75.22542369@news-text.cableinet.net...
    > Hi, I'm using ActivePerl on Win98 and this is starting to annoy me.
    > Why isn't \n accepted as a carriage return when I'm using sockets?
    > If I run the following program, I get no response other than the SMTP info
    > header. Using a proxy to investigate, I found that what is getting sent to
    > the server is only an 0a character not an 0d0a sequence, any help on this
    > would be great appreciated. I've already tried sending \r\n and that makes
    > no difference.
    >
    > #!/usr/bin/perl -w
    > use IO::Socket;
    > $remote = IO::Socket::INET->new(
    > Proto => "tcp",
    > PeerAddr => "smtp_host",
    > PeerPort => "25",
    > )
    > or die "cannot connect to server";
    > # get SMTP server welcome
    > $line=<$remote>;
    > print "$line\n";
    >
    > # send HELO
    > print $remote "HELO\n"; # the \n here doesn't seem to work
    >
    > # get reply
    > $line=<$remote>;
    > print "$line\n";
    >
    >




+ Reply to Thread

Similar Threads

  1. Signing headers with carriage returns
    By Application Development in forum DOTNET
    Replies: 0
    Last Post: 04-27-2007, 01:54 AM
  2. Preserve all whitespace characters BUT for carriage returns
    By Application Development in forum XML SOAP
    Replies: 0
    Last Post: 08-07-2006, 09:53 AM
  3. Remove carriage returns
    By Application Development in forum awk
    Replies: 5
    Last Post: 05-10-2006, 07:48 AM
  4. Re: Formatting/Carriage returns not displayed in output.asp
    By Application Development in forum Inetserver
    Replies: 0
    Last Post: 10-22-2003, 07:35 PM
  5. Re: Formatting/Carriage returns not displayed in output.asp
    By Application Development in forum Inetserver
    Replies: 0
    Last Post: 10-10-2003, 12:47 PM