Package java.nio.channels

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


                continue;
            }

            // 2. Create a ServerSocketChannel
            sock_channel=ServerSocketChannel.open();
            sock_channel.configureBlocking(false);
            sock_channel.socket().bind(key);

            // 3. Register the selector with all server sockets. 'Key' is attachment, so we get it again on
            //    select(). That way we can associate it with the mappings hashmap to find the corresponding
            //    value
View Full Code Here


        {
          ServerSocketChannel channel = ServerSocketChannel.open();
         
          try
          {
            channel.configureBlocking(false);
            channel.socket().bind(new InetSocketAddress(anyLocalAddressIPv6, 0));
            Logger.log(new LogEvent(LOGID, "NetworkAdmin: testing nio + ipv6 bind successful"));

            supportsIPv6withNIO = true;
          } catch (Exception e)
View Full Code Here

    private ServerSocket serverSocket;
   
    public NioSocketServer(boolean useNIO) throws IOException {
        if (useNIO) {
            ServerSocketChannel ssc = ServerSocketChannel.open();
            ssc.configureBlocking(false);
            ServerSocket ss = ssc.socket();
            ss.bind(new InetSocketAddress(LISTEN_PORT));
           
            this.selector = Selector.open();
            ssc.register(this.selector, SelectionKey.OP_ACCEPT);
View Full Code Here

        ServerSocketChannel channel = null;

        try
        {
            channel = ServerSocketChannel.open();
            channel.configureBlocking( false );
            channel.socket().setReuseAddress( true );
            InetSocketAddress address = new InetSocketAddress( _serverInfo.getInterface(), _serverInfo.getPort() );
            channel.socket().bind( address, 1024 );
            this._serverInfo.setHost( address.getHostName() + ':' + address.getPort() );
            // this._connectionHeader.setChannel(channel);
View Full Code Here

        try
        {
            ServerSocketChannel ssc = ServerSocketChannel.open();
           
            // Set it to non-blocking, so we can use select
            ssc.configureBlocking( false );
           
            // Get the Socket connected to this channel, and bind it
            // to the listening port
            ServerSocket ss = ssc.socket();
            InetSocketAddress isa = new InetSocketAddress( port );
View Full Code Here

        // create a new Selector for use below
        selector = Selector.open();
        // set the port the server channel will listen to
        serverSocket.bind (new InetSocketAddress (bind,tcpListenPort));
        // 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
View Full Code Here

            serverSocket.setReuseAddress(false); // fix for Apple JVM bug 3922515
            InetSocketAddress listenAddress = new InetSocketAddress(listenPort);
            serverSocket.bind(listenAddress);
           
            // prepare for non-blocking, selectable IO
            serverChannel.configureBlocking(false);
            serverChannel.register(connectionManager.getNIODaemon().getSelector(), SelectionKey.OP_ACCEPT);
            connectionManager.getNIODaemon().setServer(connectionManager);
   
            // bind success
            logger.info("Connection Manager ready, listening on " + listenAddress);
View Full Code Here

    public <C> Listener<C> createListener(String host, int port, C context)
    {
        try
        {
            ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
            serverSocketChannel.configureBlocking(false);
            ServerSocket serverSocket = serverSocketChannel.socket();
            serverSocket.bind(new InetSocketAddress(host, port));
            return createListener(serverSocketChannel, context);
        }
        catch (ClosedChannelException e)
View Full Code Here

        }
        int endPort = maxPort;
        if (endPort < startPort)
            endPort = startPort;
        ServerSocketChannel ssc = ServerSocketChannel.open();
        ssc.configureBlocking(false);
        for( int i=startPort; i<=endPort; i++ ) {
            try {
                InetSocketAddress iddr = null;
                if( inet == null ) {
                    iddr = new InetSocketAddress( i);
View Full Code Here

        while ((request = this.requestQueue.poll()) != null) {
            SocketAddress address = request.getAddress();
            ServerSocketChannel serverChannel;
            try {
                serverChannel = ServerSocketChannel.open();
                serverChannel.configureBlocking(false);
            } catch (IOException ex) {
                throw new IOReactorException("Failure opening server socket", ex);
            }
            try {
                serverChannel.socket().bind(address);
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.