in reply to Two TCP Connections, one script

Let me recommend a third alternative to fork or threads. Use IO::Select to manage reading from the sockets whenever data is available.

I guess that handling a disconnected socket is also possible if you detect that you get a timeout while waiting for data.