my($handle, $port) = Net::Daemon::Test->Child ($numTests, $^X, 't/server', '--timeout', 20, '--mode=threads'); print "Making first connection to port $port...\n"; $fh = IO::Socket::INET->new('PeerAddr' => '127.0.0.1', 'PeerPort' => $port); printf("%s 3\n", $fh ? "ok" : "not ok"); eval { for (my $i = 0; $i < 20; $i++) { if (!$fh->print("$i\n") || !$fh->flush()) { die "Error while writing $i: " . $fh->error() . " ($!)"; } my $line = $fh->getline(); die "Error while reading $i: " . $fh->error() . " ($!)" unless defined($line); die "Result error: Expected " . ($i*2) . ", got $line" unless ($line =~ /(\d+)/ && $1 == $i*2); } };