IO::Socket::INET::Daemon is a very simple and straightforward TCP server.
SYNOPSIS
use IO::Socket::INET::Daemon;
my $host = new IO::Socket::INET::Daemon(
port => 5000,
timeout => 20,
callback => {
add => &add,
remove => &remove,
data => &data,
},
);
$host->run;
sub add {
my $io = shift;
$io->print("Welcome, ", $io->peerhost, ".n");
return !0;
}
sub remove {
my $io = shift;
warn $io->peerhost, " left.n";
}
sub data {
my ($io, $host) = @_;
my $line = $io->getline;
$line =~ s/r?n//;
if($line eq 'quit') {
$io->print("Bye.n");
return 0;
}
elsif($line eq 'stop') {
$host->stop;
}
else {
$io->print("You wrote: $linen");
return !0;
}
}
This modules aims to provide a simple TCP server. It will listen on a port you specify, accept incoming connections and remove them again when they're dead. It provides three simple callbacks at the moment, but I plan to add a few more.
Product's homepage
Requirements:
· Perl