B
Bigus
In the program below (Thomas - you may be interested in this - as I've
finally got out of the blocking scenario!
I can connect and receive data
from a mailing list system's command interpretter.
However, I do not get back ALL the data that the mailing list system wants
to send me. That is, in the initial binary part of the reply I get back from
the server it indicates that there are, eg: 80,000 bytes to send me, but I
only get back 16KB (this figure varies) before the data cuts off and the
program stops running.
Is there some sort of default limit at work in the socket module that is
causing this, or is it something completely different? (this is my first
foray into sockets, so forgive me if I'm missing some fundamental thing
about how sockets work).
Thanks
Bigus
Here's the code ->
==== code follows ====
use strict;
use warnings;
my $email = '(e-mail address removed)'
my $cmd = "review LISTNAME msg pw=password";
# --- Connect to Listserv --- #
use IO::Socket;
my $lsv = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "localhost",
PeerPort => '2306')
or die print "Connection problem :$!";
# --- Send Command --- #
# form binary part of command header
my $len = length($email)+length($cmd)+1;
my $bin =
pack("a*CCCa*","\r\n",int($len/256),$len-(int($len/256)*256),length($email),
$email);
# send command header
print $lsv "1B".$bin;
recv($lsv, my $ans, 100, 0);
if($ans !~ /^250/){print "Failed because $ans\n"; exit;}
# followed by command itself
print $lsv "$cmd\n";
# --- Get Reply --- #
# get binary part of reply & decode
recv($lsv, $ans, 8, 0);
my @an = $ans =~ /.{4}/g;
my $rcode = unpack("N",$an[0]);
my $rlen = unpack("N",$an[1]);
if($rcode != 0){print "Failed on $rcode (len $rlen)\n"; exit;}
# and get reply itself
recv($lsv, my $reply, $rlen, 0);
print "$reply\n\nHeader: $rcode - $rlen";
# --- Close Socket --- #
close $lsv;
finally got out of the blocking scenario!
from a mailing list system's command interpretter.
However, I do not get back ALL the data that the mailing list system wants
to send me. That is, in the initial binary part of the reply I get back from
the server it indicates that there are, eg: 80,000 bytes to send me, but I
only get back 16KB (this figure varies) before the data cuts off and the
program stops running.
Is there some sort of default limit at work in the socket module that is
causing this, or is it something completely different? (this is my first
foray into sockets, so forgive me if I'm missing some fundamental thing
about how sockets work).
Thanks
Bigus
Here's the code ->
==== code follows ====
use strict;
use warnings;
my $email = '(e-mail address removed)'
my $cmd = "review LISTNAME msg pw=password";
# --- Connect to Listserv --- #
use IO::Socket;
my $lsv = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "localhost",
PeerPort => '2306')
or die print "Connection problem :$!";
# --- Send Command --- #
# form binary part of command header
my $len = length($email)+length($cmd)+1;
my $bin =
pack("a*CCCa*","\r\n",int($len/256),$len-(int($len/256)*256),length($email),
$email);
# send command header
print $lsv "1B".$bin;
recv($lsv, my $ans, 100, 0);
if($ans !~ /^250/){print "Failed because $ans\n"; exit;}
# followed by command itself
print $lsv "$cmd\n";
# --- Get Reply --- #
# get binary part of reply & decode
recv($lsv, $ans, 8, 0);
my @an = $ans =~ /.{4}/g;
my $rcode = unpack("N",$an[0]);
my $rlen = unpack("N",$an[1]);
if($rcode != 0){print "Failed on $rcode (len $rlen)\n"; exit;}
# and get reply itself
recv($lsv, my $reply, $rlen, 0);
print "$reply\n\nHeader: $rcode - $rlen";
# --- Close Socket --- #
close $lsv;