TCPSocket: add isValid() to check connection status