Code example for ServerSocketChannel

Methods: registersocketconfigureBlocking

    protected void bind() throws IOException { 
        // allocate an unbound server socket channel 
        serverChannel =;
        // Get the associated ServerSocket to bind it with 
        ServerSocket serverSocket = serverChannel.socket();
        // create a new Selector for use below 
        selector =;
        // set the port the server channel will listen to 
        //serverSocket.bind(new InetSocketAddress(getBind(), getTcpListenPort())); 
        // set non-blocking mode for the listening socket 
        // register the ServerSocketChannel with the Selector 
        serverChannel.register(selector, SelectionKey.OP_ACCEPT);
    public void addEvent(Runnable event) {
        if ( selector != null ) {
Stop searching for code, let great code find you!  Add Codota to your java IDE