From 527eebe7f5f019270af6a9ccd40551d550b20711 Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Sun, 8 May 2011 18:45:41 +0200 Subject: [PATCH] splittest fix --- test/splittest.pl | 8 ++++---- test/testServer.c | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/splittest.pl b/test/splittest.pl index 9794390..f467b67 100755 --- a/test/splittest.pl +++ b/test/splittest.pl @@ -4,8 +4,9 @@ use warnings; use IO::Socket; $| = 1; -print "Usage: splittest.pl [ [ [-v]]]\n" and exit unless @ARGV; -my $port = $ARGV[1] || 4440; +print "Usage: splittest.pl [[:] [ [-v]]]\n" and exit unless @ARGV; +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 $verbose = $ARGV[3]; @@ -13,8 +14,7 @@ open FILE, '<', $ARGV[0] or die "$ARGV[0]: $!\n"; my $file = ''; $file .= $_ while ; close FILE; -my $s = IO::Socket::INET->new(Proto => "tcp", PeerAddr => "localhost", PeerPort => $port) or die "localhost:$port: $!\n"; -$s->autoflush(1); +my $s = IO::Socket::INET->new(Proto => "tcp", PeerAddr => $host, PeerPort => $port) or die "$host:$port: $!\n"; my $c = 0; while ($c < length $file) { diff --git a/test/testServer.c b/test/testServer.c index 255d425..4d15d68 100644 --- a/test/testServer.c +++ b/test/testServer.c @@ -233,6 +233,11 @@ int main (int argc, char **argv) } else { + if (verbose >= 2) + printf("> %ld bytes\n", nbytes); + if (verbose >= 3) + printf("> [%.*s]", (int)nbytes, recvbuf); + // we got some data from a client parsebuf = recvbuf - contbytes; psyc_setParseBuffer2(&parsers[i], parsebuf, contbytes + nbytes);