in reply to
Please try to edit your posts to add/correct things instead of making new ones with the same question. http://perlmonks.org/?node_id=723152
It is definitely possible to have sockets die without notice, such that the while loop won't exit. I suffered that when I wrote a telnet-based multiplayer market trading game.
What I did was to select from the current connections, and carefully read a byte at a time.
Once there is enough to act on, I call whatever functions need calling. (If not, buffer the input so far, and loop back to the select)
If one of the connections dies silently and unexpectedly, the select won't pick it to read from since there is no more input to read. After a few minutes of no activity, the dead/timed-out connections can be closed.