Listening on port 50000 (Avaya CDR), the script creates the output file, receives the data stream on port 50000, prints fine to the screen, but does not write to the output file. What am I missing?
use IO::Socket;
use POSIX;
$port = 50000;
for(;;){
my $sock = IO::Socket::INET->new(
Listen => 5,
LocalPort => $port,
Proto => 'tcp'
) or die "Can't create server socket: $!";
my $client = $sock->accept;
open FILE, ">output" or die "Can't open: $!";
while (<$client>) {
s/^\0+//; # Remove leading null characters
print $_;
print FILE $_;
}
#close the socket
close $sock or die "close: $!";
close FILE;
}