Forking ssl webserver
am 18.04.2005 05:22:11 von jkeller------=_NextPart_000_0069_01C5442A.6475BCC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I'm trying to build a ssl web server that will allow mutiple connections =
at once. I'm using HTTP::Daemon::SSL, my code is pasted below.
The forking seems to be working however if I telnet to the port the =
daemon is running on, then send lots of request to the daemon via a web =
browser, after about 10 reloads the browser stops getting responses from =
the serer. Once I close the other connection to the daemon, the browser =
gets the response its suppose to. The $rand is just to show that the =
response is different from the last one.
The same thing seems to happen to a non ssl daemon.
Could someone point me in the right direction for making an ssl daemon =
that supports multiple connections?
Thanks in advance.
#!/usr/bin/perl
$| =3D 1;
use HTTP::Daemon::SSL;
use HTTP::Status;
use Net::SSLeay;
use URI::URL;
use strict;
# Make sure you have a certs/ directory with "server-cert.pem"
# and "server-key.pem" in it before running this!
my $d =3D HTTP::Daemon::SSL->new(
LocalPort =3D> $ARGV[0],
Listen =3D> 20,
Timeout =3D> 5,
Reuse =3D> 1
) || die;
print "Please contact me at:
while (my ($c) =3D $d->accept) {
my $pid =3D fork();
if ($pid == 0) {
while (my $r =3D $c->get_request) {
my $rand =3D rand(100);
print "Got Request $rand " . $r->method . "\n";
my $res =3D HTTP::Response->new(200);
$res->content("Hello there $rand");
$c->send_response($res);
}
$c->close;
undef($c);
exit(0);
}
}
close($d);
------=_NextPart_000_0069_01C5442A.6475BCC0--