my $asock = new IO::Socket::INET (..., Listen => 5); # accepting socket my $sslsock = new IO::Socket::SSL(..., PeerAddr => ...,); # SSL socket while (1) { my $csock = $psock->accept(); # Accept $csock, connecting socket if (my $p = fork()) { my $line; $sslsock->print($line) while (defined($line = <$csock>)); # Now the connecting socket disconnected kill 1, $p; wait (); } else { my $line; $csock->print($line) while (defined($line = <$sslsock>)); # Lost SSL connection... this may cause our parent to block # forever, but this is just for demonstration of the Real problem... exit; } }