my $d = HTTP::Daemon::SSL->new(LocalAddr => localhost, LocalPort => 9090, ReuseAddr => 1) || die "Couldn't start server! Reason: $!"; print "Serving as (".$$.") on ".$d->sockhost.":".$d->sockport."\n"; while (my $c = $d->accept) { threads->create(\&handle, $c)->detach(); } sub handle { my $c = shift; my $r = $c->get_request; if ($r) { ... } else { $c->send_error(); } $c->close; undef($c); }