#!/usr/bin/perl -w

use strict;
use warnings;
use IO::Socket::UNIX;

my $Server = $ARGV[0];

my $sock = new IO::Socket::UNIX(Peer => $Server, Type => SOCK_DGRAM) or
	die("cannot connect: $!, stopped");


my ($QueueLen) = (`sysctl net.unix.max_dgram_qlen` =~ /(\d+)/);

my $lastTime = time();
printf("%d sending with max queue length of %d messages\n",
    $lastTime, $QueueLen);

for (my $msg = 1; $sock; ++$msg) {
	$sock->send($msg) or die("cannot send: $!, stopped");
	my $now = time();
	printf("%d sent msg #%02d after %.2f seconds\n",
		$now, $msg, $now - $lastTime);
	$lastTime = $now;
	#sleep(1);
}

print("Done: $!.\n");
exit 0;

