in reply to monitor tcp stream but alert if no info in xx mins

You could use select instead of <...> to wait for data to appear in the socket. Specify a timeout bigger than XX minutes. If select returns due to timeout, kill the connection. Alternatively, alarm might be of use.

Replies are listed 'Best First'.
Re^2: monitor tcp stream but alert if no info in xx mins
by bengmau (Beadle) on Jun 29, 2005 at 15:41 UTC
    little unclear on the syntax for select in this context. can you provide a quickie example? Thanks
      oh yeah, I forgot how unfriendly it is. There's an class that helps in this case:
      my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp'); my $sel = IO::Select->new($sock); open (FILEOUT, '>', 'output.log'); my @msgstream; while ($sel->can_read($timeout)) { my $line = <$sock>; ... }

      By the way, this thread discusses how to use a second process.