in reply to socket server threads or fork
Also, have a look in the CPAN library, and do some serious soul-searching here. There are many workload-server systems (POE is only one). You don’t have to start from scratch here.
A principle that you will see in your investigations is that most-often there is not either a thread or a process “per connection,” because that does not scale well. Instead, when a socket connection is accepted, the request (and socket handle) are handed to a pool of service processes/threads, which remove the request from a queue and process it. These threads survive to process many requests during their lifetime, and there’s never more than a specified number of them, nor less than another specified number, no matter how many requests are in-process or waiting to be processed at a time. To prevent flooding, the systems won’t allow the total request-count to grow too large.
“Do not do a thing already done.™”