public String register(SocketChannel channel, PortType portType) throws IOException {
    Socket socket = channel.socket();
    String connectionId = generateConnectionId(channel);
    SelectionKey key = channel.register(nioSelector, SelectionKey.OP_READ);
    Transmission transmission;
    try {
      transmission =
          createTransmission(connectionId, key, socket.getInetAddress().getHostName(), socket.getPort(), portType,
              SSLFactory.Mode.SERVER);
    } catch (IOException e) {
      logger.error("IOException on transmission creation ", e);
      socket.close();
      channel.close();
      throw e;
    }
    key.attach(transmission);
    this.keyMap.put(connectionId, key);
    numActiveConnections.set(this.keyMap.size());
    return connectionId;
  }
Register the nioSelector with an existing channel
Use this on server-side, when a connection is accepted by a different thread but processed by the Selector
Note that we are not checking if the connection id is valid - since the connection already exists
ambry-network/src/main/java/com/github/ambry/network/Selector.java