1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

splittest fix

This commit is contained in:
tg(x) 2011-05-08 18:45:41 +02:00
parent 00e319d8f4
commit 527eebe7f5
2 changed files with 9 additions and 4 deletions

View file

@ -4,8 +4,9 @@ use warnings;
use IO::Socket; use IO::Socket;
$| = 1; $| = 1;
print "Usage: splittest.pl <packet file> [<port> [<chunk length> [-v]]]\n" and exit unless @ARGV; print "Usage: splittest.pl <packet file> [[<host>:]<port> [<chunk length> [-v]]]\n" and exit unless @ARGV;
my $port = $ARGV[1] || 4440; my ($host, $port) = $ARGV[1] =~ /^(?:([a-z0-9.-]+):)?(\d+)$/i;
$host ||= 'localhost'; $port ||= 4440;
my $length = int($ARGV[2] || 1); $length = 1 if $length < 1; my $length = int($ARGV[2] || 1); $length = 1 if $length < 1;
my $verbose = $ARGV[3]; my $verbose = $ARGV[3];
@ -13,8 +14,7 @@ open FILE, '<', $ARGV[0] or die "$ARGV[0]: $!\n";
my $file = ''; $file .= $_ while <FILE>; my $file = ''; $file .= $_ while <FILE>;
close FILE; close FILE;
my $s = IO::Socket::INET->new(Proto => "tcp", PeerAddr => "localhost", PeerPort => $port) or die "localhost:$port: $!\n"; my $s = IO::Socket::INET->new(Proto => "tcp", PeerAddr => $host, PeerPort => $port) or die "$host:$port: $!\n";
$s->autoflush(1);
my $c = 0; my $c = 0;
while ($c < length $file) { while ($c < length $file) {

View file

@ -233,6 +233,11 @@ int main (int argc, char **argv)
} }
else else
{ {
if (verbose >= 2)
printf("> %ld bytes\n", nbytes);
if (verbose >= 3)
printf("> [%.*s]", (int)nbytes, recvbuf);
// we got some data from a client // we got some data from a client
parsebuf = recvbuf - contbytes; parsebuf = recvbuf - contbytes;
psyc_setParseBuffer2(&parsers[i], parsebuf, contbytes + nbytes); psyc_setParseBuffer2(&parsers[i], parsebuf, contbytes + nbytes);