ARCv2
view release on metacpan or search on metacpan
lib/Arc/Server.pm view on Meta::CPAN
$this->{server}->{port} = [$Arc::DefaultPort];
}
# net::server::* initilizations
$this->{server}->{proto} = 'tcp';
$this->{server}->{listen} = SOMAXCONN;
$this->{server}->{child_communication} = undef,
}
## start the server
## This function is used by the user to start the server and enter the main accept-loop.
## Only by calling the C<Interrupt> function this call can be aborted.
##out> return true if everything worked fine, otherwise false is returned and C<IsError> should be checked.
##eg> $arc->Start();
sub Start
{
my $this = shift;
my $ct = $this->{connection_type};
eval "require $ct";
croak "Please \"use $ct\" before calling Start(): $@" if $@;
$this->run();
return 1;
}
# Net::Server::* hooks and overrides
sub process_request
{
my $this = shift;
my $arc = $this->{__arc};
# my $arc = new Arc::Connection::Server(
# %{$this->{connection_vars}},
# );
return $this->_SetError("No Arc::Connection::Server object was created.")
unless $arc;
$this->Log(LOG_USER,"Client connection from",$this->{server}->{client}->peerhost);
$arc->HandleClient($this->{server}->{client});
$arc->clean;
$this->Log(LOG_USER,"Client connection closed.");
}
sub write_to_log_hook
{
my ($this,$loglevel,$msg) = @_;
$msg =~ s/[\n\r]//g;
$this->Log(LOG_SIDE,$msg);
1;
}
sub child_init_hook
{
my $this = shift;
my $ct = $this->{connection_type};
$this->{__arc} = new $ct (
%{$this->{connection_vars}},
);
}
# deleting STDIN and STDOUT kills ARCv2, don't know if Net::Server does
# is right
sub post_accept
{
my $this = shift;
my $prop = $this->{server};
### keep track of the requests
$prop->{requests} ++;
}
1;
( run in 0.596 second using v1.01-cache-2.11-cpan-ceb78f64989 )