In the first edition of Programming Perl there was an example program called receptionist which provided similar functionality to inetd. Of course it is perl 4 but despite the fact that you would probably do things differently now it is still a good example.
The examples can be found at ftp://ftp.ora.com/published/oreilly/perl/programming_perl/perl.tar.Z
Added Later:
Well of course I started to think about this and wondered how I might do this on windows and I came up with this basic example:
#!/usr/bin/perl -w
use strict;
use Socket;
use IO::Select;
use IO::Socket;
my $select = IO::Select->new();
while(<DATA>)
{
chomp;
if ( my $server = IO::Socket::INET->new(LocalPort => $_,
Listen => 10,
ReuseAddr => 1) )
{
$select->add($server);
}
}
while(1)
{
foreach my $ready ($select->can_read(1))
{
my $client = $ready->accept();
print inet_ntoa($client->peeraddr()),
" ",$client->sockport(),"\n";
}
}
__DATA__
2048
2049
2060
The ports that you want to monitor are the numbers after the __DATA__ . You can probably take the rest from there :)
/J\
|