Examples of configureBlocking()


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

            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

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

    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

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

 
  @Override
  public void handleAccept(SelectionKey key) throws IOException {
    logger.debug("handle accept...");
    SocketChannel clientChannel = ((ServerSocketChannel) key.channel()).accept();
    clientChannel.configureBlocking(false);
    IOLoop.INSTANCE.addHandler(clientChannel, this, SelectionKey.OP_READ, ByteBuffer.allocate(READ_BUFFER_SIZE));
  }
 
  @Override
  public void handleConnect(SelectionKey key) throws IOException {
View Full Code Here

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

            ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
            SocketChannel socketChannel = serverChannel.accept();
            if(LOG.isDebugEnabled()) {
                LOG.debug("accepted a connection from " + socketChannel.socket().getInetAddress());
            }
            socketChannel.configureBlocking(false);
            socketChannel.register(key.selector(), SelectionKey.OP_READ, nextHandler);
        }

    }
View Full Code Here

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

    private static SocketChannel createSocketChannel(final SocketAddress sockAddr, final boolean blocking, final int rcvbufSize) {
        final SocketChannel ch;
        try {
            ch = SocketChannel.open();
            ch.configureBlocking(blocking);
        } catch (IOException e) {
            LOG.error("Failed to open SocketChannel.", e);
            throw new IllegalStateException(e);
        }
        final Socket sock = ch.socket();
View Full Code Here

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

      SocketChannel socketChannel = selector.provider().openSocketChannel();
      Socket socket = socketChannel.socket();
      socket.setTcpNoDelay(true);
      socket.setTrafficClass(IPTOS_LOWDELAY);
      socket.connect(remoteAddress, timeout); // Connect using blocking mode for simplicity.
      socketChannel.configureBlocking(false);
      this.socketChannel = socketChannel;

      selectionKey = socketChannel.register(selector, SelectionKey.OP_READ);
      selectionKey.attach(this);
View Full Code Here

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

  outgoing()
  {
    try{     
      final SocketChannel  channel = SocketChannel.open();
     
      channel.configureBlocking( false );
   
      if ( channel.connect( new InetSocketAddress("localhost", 8765 ))){
             
        outgoing( channel );
       
View Full Code Here

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

       
          socket_channel.close();
         
        }else{
           
          socket_channel.configureBlocking(false);
 
          AEProxyConnectionImpl processor = new AEProxyConnectionImpl(this, socket_channel, proxy_handler);
         
          if ( !processor.isClosed()){
           
View Full Code Here

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

        while (i.hasNext()) {
            SelectionKey key = (SelectionKey) i.next();
            if (key.isAcceptable()) {
                ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
                SocketChannel sc = ssc.accept();
                sc.configureBlocking(false);
                sc.register(this.selector, SelectionKey.OP_READ);
            } else if (key.isReadable()) {
                SocketChannel sc = (SocketChannel) key.channel();
                ByteBuffer buffer = ByteBuffer.allocate(10);
                buffer.clear();
View Full Code Here

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

    // channel.
    ServerSocketChannel serverSocketChannel = (ServerSocketChannel) key.channel();

    // Accept the connection and make it non-blocking
    SocketChannel socketChannel = serverSocketChannel.accept();
    socketChannel.configureBlocking(false);

    // Register the new SocketChannel with our Selector, indicating
    // we'd like to be notified when there's data waiting to be read
    socketChannel.register(this.selector, SelectionKey.OP_READ);
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.