You should probably use IO::Select to show how simple
multiplexing IO can be done, or at least use non-blocking
sockets ($socket->blocking(0)). The next
question people ask is often along these lines, so take
the initiative.
If you're using IO::Socket, you should say $socket->close()
instead of close($socket). Use object methods wherever possible.
Likewise, you could be using $socket->getline() instead of
<$socket> to read a single line. If you're so
embittered about using IO::Handle ("thousands of lines")
then why not make more use of it?
s/protocal/protocol/i
I'm not sure why you've indented your entire program four
spaces. It ruins registration and is causing massive linewrapping
problems in the PM code display window
Your program is "paranoid" in that you are checking
for a condition which can never be true. According to your
code, there is no way that $mode could ever be 1 or 2, and
you are checking for a hypothetical third condition. The only
way this is going to happen is if you have bad ram, aliens
abduct your computer, or you're hacking around in the debugger.
Read up on IPC pipe code, and then post your
explanation too. No sense in answering questions with a
question.