femerrill has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: can't write to file from socket
by GotToBTru (Prior) on Aug 04, 2014 at 15:32 UTC | |
by femerrill (Initiate) on Aug 04, 2014 at 17:57 UTC | |
|
Re: can't write to file from socket (flush)
by tye (Sage) on Aug 04, 2014 at 16:42 UTC | |
by femerrill (Initiate) on Aug 04, 2014 at 18:28 UTC | |
|
Re: can't write to file from socket
by Anonymous Monk on Aug 05, 2014 at 12:55 UTC |