2 Einträge, 1 Seite |
Quote
# Handle the client's connection and spawn off a new parser.
# This can/should be a fork() or a new thread,
# but for simplicity...
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
use strict;
use warnings;
use Carp;
use Net::SMTP::Server;
use Net::SMTP::Server::Client;
use Net::SMTP;
use File::Log;
use Config::General;
use Init;
$Net::SMTP::Server::server = new Net::SMTP::Server($Init::config{ip}, $Init::config{port}) || croak(getTime()." Unable to create Mailer deamon for host $Init::config{ip} at Port $Init::config{port}: ".$!."\n");
while(my $conn = $Net::SMTP::Server::server->accept())
{
if (!defined(my $kidpid = fork()))
{
die "Cannot fork: $!";
} elsif ($kidpid == 0)
{
# fork returned 0, so this branch is child
my $client;
$Net::SMTP::Server::Client::client = new Net::SMTP::Server::Client($conn) ||
croak(getTime()." Unable to handle client connection: $!\n");
$Net::SMTP::Server::Client::client->process;
my $from = $client->{FROM};
my $to = $client->{TO}[0];
my $msg = $client->{MSG};
exit(0);
} else
{
# fork returned 0 nor undef
# so this branch is parent
waitpid($kidpid, 0);
$Init::log->close();
}
}
2 Einträge, 1 Seite |