I'm writing external application in Perl that connects to LMCE system over IO::Socket::INET tcp connection.
Sometimes it happens that other client closes tcp connection, but my app happily goes on, sending things to dead TCP socket.
What are proper ways to prevent such state and check if TCP port is alive or better said other client didn't close TCP connection ?