Package java.nio.channels

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


                                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

                // 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

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

    }

    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

    /*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

      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

        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

                       
                        //
                        // Force the client socket to be blocking
                        //
                        synchronized (connected.blockingLock()) {
                            connected.configureBlocking(false);
                            connected.configureBlocking(true);
                        }
       
                        // otherwise one key has been selected (ours) so we get the channel and hand it off
                        socket.initSocket(context.getRuntime(), new ChannelDescriptor(connected, RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));
View Full Code Here

                        //
                        // Force the client socket to be blocking
                        //
                        synchronized (connected.blockingLock()) {
                            connected.configureBlocking(false);
                            connected.configureBlocking(true);
                        }
       
                        // otherwise one key has been selected (ours) so we get the channel and hand it off
                        socket.initSocket(context.getRuntime(), new ChannelDescriptor(connected, RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));
                    } catch (InvalidValueException ex) {
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.