sub sampleNode { my ($msg, $peerAddr, $eTime) = @_; my $bol = 0; print "Sending the message to the server for node $msg...\n"; $MySocket = new IO::Socket::INET->new( PeerPort => 6060, Proto => 'udp', PeerAddr => $peerAddr, ); ioctl($MySocket, 0x8004667e, pack("I", 1)); $MySocket->send($msg); while((time() < $eTime) && (!$bol)) { #print "time: " . time() . ", threshold: $eTime\n"; $MySocket->recv($text,128); print $text; if($text =~ /OK/) { print "Received ok response: $text"; $bol = 1; } } return $bol; }