Code example for ServerSocketChannel

Methods: registersocketconfigureBlocking

    public Listener() throws IOException { 
      address = new InetSocketAddress(bindAddress, port);
      // Create a new server socket and set to non blocking mode 
      acceptChannel =;
      // Bind the server socket to the local host and port 
      bind(acceptChannel.socket(), address, backlogLength);
      port = acceptChannel.socket().getLocalPort(); //Could be an ephemeral port
      // create a selector; 
      // Register accepts on the server socket with the selector. 
      acceptChannel.register(selector, SelectionKey.OP_ACCEPT);
      this.setName("IPC Server listener on " + port);
    /** cleanup connections from connectionList. Choose a random range 
     * to scan and also have a limit on the number of the connections