pascaldee has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Timing-out network clients?
by TOD (Friar) on Dec 02, 2007 at 04:51 UTC | |
|
Re: Timing-out network clients?
by erroneousBollock (Curate) on Dec 03, 2007 at 02:12 UTC | |
by pascaldee (Acolyte) on Dec 05, 2007 at 07:12 UTC |