Package java.nio.channels

Examples of java.nio.channels.ServerSocketChannel.register()


        // set the port the server channel will listen to
        serverSocket.bind (new InetSocketAddress (bind,port));
        // set non-blocking mode for the listening socket
        serverChannel.configureBlocking (false);
        // register the ServerSocketChannel with the Selector
        serverChannel.register (selector, SelectionKey.OP_ACCEPT);
        while (doListen) {
            // this may block for a long time, upon return the
            // selected set contains keys of the ready channels
            int n = selector.select();
            if (n == 0) {
View Full Code Here


       
        ServerSocketChannel server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        server.socket().bind(new InetSocketAddress("127.0.0.1", startingPort + ACCEPT_THEN_CLOSE));
        server.configureBlocking(false);
        server.register(selector, SelectionKey.OP_ACCEPT);
        SelectionKey key = server.keyFor(selector);
        key.attach(new AcceptThenClose(server));
       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
View Full Code Here

       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        server.socket().bind(new InetSocketAddress("127.0.0.1", startingPort + PB_CLOSE_BEFORE_WRITE ));
        server.configureBlocking(false);
        server.register(selector, SelectionKey.OP_ACCEPT);
        key = server.keyFor(selector);
        key.attach(new AcceptReadThenClose(server));
       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
View Full Code Here

       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        server.socket().bind(new InetSocketAddress("127.0.0.1", startingPort + PB_FULL_WRITE_THEN_CLOSE ));
        server.configureBlocking(false);
        server.register(selector, SelectionKey.OP_ACCEPT);
        key = server.keyFor(selector);
        key.attach(new AcceptReadWriteThenClose(server));
       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
View Full Code Here

       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        server.socket().bind(new InetSocketAddress("127.0.0.1", startingPort + PB_PARTIAL_WRITE_THEN_CLOSE));
        server.configureBlocking(false);
        server.register(selector, SelectionKey.OP_ACCEPT);
        key = server.keyFor(selector);
        key.attach(new AcceptReadPartialWriteThenClose(server));
       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
View Full Code Here

       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        server.socket().bind(new InetSocketAddress("127.0.0.1", startingPort + PB_FULL_WRITE_STAY_OPEN ));
        server.configureBlocking(false);
        server.register(selector, SelectionKey.OP_ACCEPT);
        key = server.keyFor(selector);
        key.attach(new AcceptReadWriteStayOpen(server));
       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
View Full Code Here

       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        server.socket().bind(new InetSocketAddress("127.0.0.1", startingPort + PB_PARTIAL_WRITE_STAY_OPEN));
        server.configureBlocking(false);
        server.register(selector, SelectionKey.OP_ACCEPT);
        key = server.keyFor(selector);
        key.attach(new AcceptReadPartialWriteStayOpen(server));
       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
View Full Code Here

       
        server = ServerSocketChannel.open();
        server.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        server.socket().bind(new InetSocketAddress("127.0.0.1", startingPort + PB_FULL_WRITE_ERROR_STAY_OPEN ));
        server.configureBlocking(false);
        server.register(selector, SelectionKey.OP_ACCEPT);
        key = server.keyFor(selector);
        key.attach(new AcceptReadWriteErrorStayOpen(server));
    }
   
    @Override
View Full Code Here

        }
        if(log.isInfoEnabled())
            log.info("JK: ajp13 listening on " + getAddress() + ":" + port );

        selector = Selector.open();
        ssc.register(selector, SelectionKey.OP_ACCEPT);
        // If this is not the base port and we are the 'main' channleSocket and
        // SHM didn't already set the localId - we'll set the instance id
        if( "channelNioSocket".equals( name ) &&
            port != startPort &&
            (wEnv.getLocalId()==0) ) {
View Full Code Here

        final ServerSocketChannel serverChannel = ServerSocketChannel.open();
        serverChannel.configureBlocking(false);
        serverChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        final InetSocketAddress isa = new InetSocketAddress(port);
        serverChannel.socket().bind(isa);
        serverChannel.register(selector, SelectionKey.OP_ACCEPT);
        logger.info("MQTT server listening on port " + port);
    }

    private void run() {
        //noinspection InfiniteLoopStatement
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.