#! perl -slw use strict; use IO::Socket; our $N ||= 1000; our $PORT ||= 9999; our $DELAY ||= 0.0001; my $sock = IO::Socket::INET->new( Proto => 'udp', PeerPort => $PORT, PeerAddr => 'localhost' ) or die "$@ [$^E]"; my $sent = 0; for ( 1 .. $N ) { ++$sent; $sock->send( int rand( 32767 ) ); select undef,undef, undef, $DELAY; } print "Sent: $sent";