#!/usr/bin/perl use IO::Socket::INET; use IO::Select; $timeout = 180; $host = shift; $port = shift; $string = shift; my $TIMEDOUT, $counter; $MySocket = new IO::Socket::INET->new("$host:$port") or die "connect: +$@"; $command = "EDMSFT\|$string\|\@\n"; $MySocket->send($command); while (($text !~ m/$string/)&&(!$TIMEDOUT)&&($counter<30)) { if( () = IO::Select->new($MySocket)->can_read($timeout) ) { my $sender = $MySocket->recv( $text, 1024, 0 ); $counter++; ### TIMEOUT if counter hits 30 without a match } else { $TIMEDOUT=1; } } if ((!$TIMEDOUT)&&($counter<30)) { print "GOOD\n"; } else { print "TIMEDOUT\n"; } close $MySocket; exit;
In reply to Re: Using IO::Socket
by Earindil
in thread Using IO::Socket
by Earindil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |