in reply to Fork issues

Just a style comment...

Usually the way accept and fork are used together is to have the parent keep the accept socket open and fork off children to handle incoming requests:

while (1) { my $new_handle = $sock->accept; my $pid = fork; if (defined($pid) && $pid == 0) { ...child executes here... } }

This way there is no need to close the accept socket and re-create it again. In fact, doing so will drop all connections that are queued up on the accept socket. Moreover, this allows the parent to fork off another child even if the first child hasn't completed yet, i.e. you get concurrency.