Hi All,
I've successfully written quite an big perl server using IO::Socket::INET -
it seems to be working pretty darn good and so far I'm happy.
I'm attempting now to do the same but by using SSL. I've read up on
IO::Socket::SSL, and I know that there are minor changes required in terms
of how the socket is created. I've made those changes, my socket is
successfully created, but when I connect, the server is unable to fork...
The error is blank as well - which is of course helping me allot to
determine what is going wrong...
Can someone possibly shed some light for me on this?
Here's the socket and forking code:
# Open socket and listen for new connections
my $Port563 = IO::Socket::SSL->new(LocalAddr => "198.19.255.11",
LocalPort => "563",
Proto => "TCP",
Reuse => 1,
Listen => 128,
SSL_cert_file =>
"/srv/nntp/etc/cert.pem",
SSL_key_file =>
"/srv/nntp/etc/key.pem",
SSL_verify_mode => 0x01);
if (!$Port563) {
SysLog('err', 'Server failed to start: ' . $@);
die "Failed to create listening socket: " . $@ . "\n";
} else {
binmode $Port563 => ":encoding(utf8)";
SysLog('info', 'Server started: ' . $Port563->sockhost() . ':' .
$Port563->sockport());
}
# Drop privileges to normal user
drop_privileges('news');
# Wait for client connection and spawn new child
while (my $ClientSocket = $Port563->accept()) {
my $Child;
SysLog('err', 'Server failed to fork: ' . $!);
die "Can't fork: $!" unless defined ($Child = fork()); # Script errors
here. $! contains empty string
if ($Child == 0) {
$Port563->close;
&ClientConnection($ClientSocket);
undef $Childs{$Child};
exit 0;
} else {
$Childs{$Child} = 1;
$ClientSocket->close();
}
}
--
Chris.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/