What I have is a Perl script daemon that looks at a file using Tail and then outputs the data via a serial port. This works perfectly fine.
BUT, I wanted to ramp it up a bit and instead of outputting the data via serial, I want to send it via TCP.
I googled around, and found some pretty simple code, but I get unexpected results.
Basically, I dont get any data output until I stop the daemon...which I only stumbled upon when testing.
Here is part of my code:-
my $sock = new IO::Socket::INET ( PeerAddr => '192.168.1.2', PeerPort => '8000', Proto => 'tcp' ); while (defined(my $line=$file->read)) { print TTY "$line"; #out serial print $sock "$line"; #out tcp } close($sock);
As you can see, not exactly complex.
I tried moving the "my $sock" init of the socjet to just above the "print $sock" line, then closeing the socket, but this didnt really work.
I tried $sock->send(); but this didnt make any difference.
I am sure someone will spot the problem beable to tell.
Thanks, Jeremy
Edit: g0n - code tags & formatting
In reply to Perl Sockets question by jimbo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |