code: public boolean isConnected() {
      if (socket != null && socket.isConnected() && !socket.isInputShutdown() && !socket.isOutputShutdown())
        return true;
      return false;
    }
docs: Tells if the channel is connected.
  
  @return true if it's connected, otherwise false.