Examples of configureBlocking()


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

    private void handleAccept() throws IOException {
        // new incoming connection
        SocketChannel client = this.server.accept();

        // Non blocking client
        client.configureBlocking(false);

        // Register client (with an empty channel attachment)
        client.register(this.selector, SelectionKey.OP_READ, new ChannelAttachment());
    }
View Full Code Here

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

                                cChannel.socket().setReuseAddress( true );
                                cChannel.socket().setSoLinger( false, 0 );
                               
                                // ensure that the socket channel is prepared
                                // for non-blocking operations
                                cChannel.configureBlocking( false );
                                // create a new ConnectionHeader for all
                                // upcoming operations on the
                                // accepted socket connection
                                header = new ConnectionHeader( cChannel, cChannel.socket().getRemoteSocketAddress()
                                        .toString(), true );
View Full Code Here

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

                                    logger.log( Level.FINEST,
                                                "Setting socket to blocking mode for further io operations..." );

                                    // prepare the channel for upcoming blocking
                                    // network operations
                                    cChannel.configureBlocking( true );
                                }

                                // schedule a asynchronious read-process operation
                                this._readpool.invokeLater( new ConnectionReader( this, this._serverInfo, clientInfo ) );
                            }
View Full Code Here

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

                                if ( !this._serverInfo.hasNonBlockingReadWrite() )
                                {
                                    if ( !clientInfo.hasAttachment() ) continue;
                                    // prepare the channel for upcoming blocking
                                    // network operations
                                    cChannel.configureBlocking( true );
                                }

                                // schedule a asynchronious socket-write
                                // operation
                                this._writePool
View Full Code Here

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

                // mode to allow selector operations on it
                if ( channel.isBlocking() )
                {
                    logger.log( Level.FINEST,
                                "Setting socket temporarily to non-blocking until further connection processing..." );
                    channel.configureBlocking( false );
                }

                sk = channel.keyFor( this._selector );
                if ( sk == null )
                {
View Full Code Here

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

          if(sk.isAcceptable()) {
           
            SocketChannel sc = null;
            try {
            sc = this.ssChannel.accept();
            sc.configureBlocking(false);
          } catch (IOException e) {
            //TODO:记录下此异常
            e.printStackTrace();
          }
         
View Full Code Here

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

    }

    long sessionId = acceptor.getNextSessionId();

    SocketChannel sc = SocketChannel.open();
    sc.configureBlocking(false);

    SocketAddress bindAddress = acceptor.getConfigure().getAddress();

    ClientIoSession session = new ClientIoSession(sessionId, sc, acceptor, bindAddress);
View Full Code Here

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

    /*if(channel.isRegistered()) {
      throw new RuntimeException("此通道已经主册过");
    }*/

   
    channel.configureBlocking(false);                //设置为非阻塞
   
    if(session.getClass() == IoSessionImpl.class) {
      //注册
      SelectionKey selectKey = channel.register(selector, SelectionKey.OP_READ, session)//向选择器注册通道

View Full Code Here

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

      port = PookaMessagingConstants.S_PORT;
    }
    getLogger().log(Level.FINE, "opening port " + port);
    SocketAddress address = new InetSocketAddress("localhost",port);
    SocketChannel channel = SocketChannel.open();
    channel.configureBlocking(false);
    if (! channel.connect(address)) {
      // we're willing to wait for about a second.
      for (int i = 0; (! channel.finishConnect()) && i < 4; i++) {
  try {
    getLogger().log(Level.FINE, "not connected; sleeping (" + i + ").");
View Full Code Here

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

        InetSocketAddress isa = new InetSocketAddress(host, port);
        try
        {
            SocketChannel sc = SocketChannel.open();
            //        SocketChannel sc = (SocketChannel)GetChannel();
            sc.configureBlocking(false);
            if (!sc.connect(isa))
            {
                SetConnecting();
            }
            else
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.