Friends, 

I am trying to learn little bit of socket programming in Perl. I tried one
of the code snippet from Perl cookbook as a starting point. I am tring to
'talk' to my SMTP mail server. But when I type HELO through the console, it
seems like my script is not writing to the server socket and it is getting
into an inordinate wait state. What am I doing wrong? Am I not flushing the
output properly to the server socket? 

TIA,
Rex

#!/usr/bin/perl
use Socket;
use strict;
use warnings;
my($remoteHost, $remotePort)    = @ARGV or die("Usage: perl $0 hostname
portnumber\n\n");
socket(TO_SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
my $internetAddr        =       inet_aton($remoteHost)
                                                or die("FATAL: Could not
convert $remoteHost to Internet Address : $!\n\n");
my $paddr                       =       sockaddr_in($remotePort,
$internetAddr);
connect(TO_SERVER, $paddr)
        or die("FATAL: Could not connect to $remoteHost:$remotePort : $!
\n\n");
my $reply       = <TO_SERVER>;
print "Server Response: $reply\n\n";
while(my $line = <STDIN>){
                last if(uc($line) eq "Q\n");            
                print TO_SERVER "$line";
                $reply  = <TO_SERVER>;
                print "Server Response: $reply\n\n";
}
close(TO_SERVER);

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to