my $hSocket = IO::Socket::INET->new( LocalPort=>$intListenPort, Proto=>$strProtocol ) or die "Can't create UDP socket: $@"; ioctl($hSocket, 0x8004667e, pack("I", 1)); my ($datagram,$flags); # Wait for a datagram, then open a response port, respond, then close both ports. while ($hSocket->recv($datagram,42,$flags)) { ... #### until ($hSocket->accept()) { ...check for timeout ...close socket and exit if timeout } while ($hSocket->recv($datagram,42,$flags)) { ...