/**
   * Overloaded version of the handleJICPPacket() method including the <code>Connection</code> the
   * incoming JICPPacket was received from. This information is important since, unlike normal
   * mediators, a NIOMediator may not read packets from connections on its own (the
   * JICPMediatorManager does that in general).
   */
  public JICPPacket handleJICPPacket(Connection c, JICPPacket pkt, InetAddress addr, int port)
      throws ICPException {
    if (pkt.getType() == JICPProtocol.DROP_DOWN_TYPE) {
      // Note that the return packet is written inside the handleDropDown()
      // method since the connection must be closed after the response has
      // been sent back.
      handleDropDown(c, pkt, addr, port);
      return null;
    }

    checkTerminatedInfo(pkt);

    // Update keep-alive info
    lastReceivedTime = System.currentTimeMillis();

    byte type = pkt.getType();
    if (type == JICPProtocol.COMMAND_TYPE) {
      if (peerActive) {
        return outManager.handleCommand(c, pkt);
      } else {
        // The remote FrontEnd has terminated spontaneously -->
        // Kill the above container (this will also kill this NIOBEDispatcher).
        kill();
        return null;
      }
    } else if (type == JICPProtocol.KEEP_ALIVE_TYPE) {
      if (enableServerKeepAlive) {
        inpManager.sendServerKeepAlive();
      }
      return outManager.handleKeepAlive(c, pkt);
    } /* Asynch-reply
      else if (type == JICPProtocol.RESPONSE_TYPE || type == JICPProtocol.ERROR_TYPE) {
      inpManager.handleResponse(c, pkt);
      return null;
      }*/ else {
      throw new ICPException("Unexpected packet type " + type);
    }
  }