cookspyder
IS-IT--Management
I am trying to create a piece of code to open a continous socket and stream a file tail over it every time that file has a new line. The code does open the socket however no data is ever sent to the other end that i can tell. And when ever there is new data written to the tailed file the and what I assume is sent over/to the socket it closes the connection. Does any one know of a way to get thsi working?
Currently I know the tail is working because on the console I can see it print the tails as it sees new lines written but it is not sending them as far as i can tell over the socket.
Here is the code snippet.
use File::Tail;
use IO::Socket;
# init host and port
my $host = 'IP_ADDR';
my $port = 5820;
my $name = 'C:\requestDiag.log';
my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket: $!";
$file=File::Tail->new("requestDiag.log");
while (defined($line=$file->read)) {
$sock->send($line.'\n');
print "$line";
}
Thanks
Currently I know the tail is working because on the console I can see it print the tails as it sees new lines written but it is not sending them as far as i can tell over the socket.
Here is the code snippet.
use File::Tail;
use IO::Socket;
# init host and port
my $host = 'IP_ADDR';
my $port = 5820;
my $name = 'C:\requestDiag.log';
my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket: $!";
$file=File::Tail->new("requestDiag.log");
while (defined($line=$file->read)) {
$sock->send($line.'\n');
print "$line";
}
Thanks