Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Carriage Returns and sockets

Reply
Thread Tools

Carriage Returns and sockets

 
 
Iceberg
Guest
Posts: n/a
 
      09-06-2003
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 With Quote
 
 
 
 
Iceberg
Guest
Posts: n/a
 
      09-06-2003
Just found out the solution:
$EOL = "\015\012";
print $remote "HELO".$EOL;

but does anybody know any easier way?

"Iceberg" <(E-Mail Removed)> wrote in message
news:T8o6b.2420$(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Carriage returns in XML Excel sheet created using XmlDocument and XmlTextWriter st@jpa.co.jp ASP .Net 1 10-07-2005 10:47 AM
Validating Newlines and Carriage Returns via Schema Porthos XML 1 07-26-2005 11:13 PM
How to match carriage returns and line feeds Schroeder Perl 1 01-26-2005 06:53 PM
Applets: getParameter() stripping carriage-returns and line-feeds???? rrey2279@aol.com Java 3 01-17-2005 06:04 PM
Help: Delete a single carriage return in a file, but not a double carriage return? Steve Anderson Perl Misc 3 06-21-2004 12:48 AM



Advertisments