A typical network server would want to time out slow/idle network clients to keep the maximum number of connection slots available. Think Apache's TimeOut setting or qmail's timeoutconnect and timeoutremote. So far I can't figure out how to do this in Perl. Setting IO::Socket's timeout doesn't seem to do anything. Do I have to resort to alarm()?
#!/usr/bin/perl -w
use strict;
use Carp;
use Net::SMTP::Server;
use Net::SMTP::Server::Client;
my $server = new Net::SMTP::Server('localhost', 2525) or croak;
while (my $conn = $server->accept()) {
next if fork() == 0;
$conn->timeout(30);
my $client = new Net::SMTP::Server::Client($conn) or croak;
$client->process or next;
}