/usr/share/doc/libvdk2-dev/examples/iotut/iodemo-unix.pl is in libvdk2-dev 2.4.0-5.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/usr/bin/perl -w
use strict;
use IO::Socket;
use IO::Select;
use IO::Handle;
my $rendezvous = shift or die "No socket name";
my ($lsn, $flag, $fh, $buf, $sel, @ready);
$SIG{INT} = sub {
print "Close on SIGINT\n";
$lsn->close();
unlink $rendezvous;
exit()
};
sub cleansock($)
{
my $fh = $_[0];
$sel->remove($fh);
$fh->close();
}
$lsn = new IO::Socket::UNIX(Listen => 1,
Local => $rendezvous,
Proto => 'tcp',
Type => SOCK_STREAM) or die "bind $!";
$sel = new IO::Select or die "select $!";
$sel->add($lsn);
print "Listening\n";
while(@ready = $sel->can_read)
{
foreach $fh (@ready)
{
if($fh == $lsn)
{
my $ns = $fh->accept;
$sel->add($ns);
print "\nConnect\n";
}
else
{
if($fh->recv($buf, 256, 0), $buf)
{
$fh->send((length($buf)-1)." -> ".$buf, 0);
}
else
{
print "Closed\n";
cleansock($fh);
}
}
}
}
|