Package java.nio.channels

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


      // accept up to 10 connections
      for (int i=0; i<10; i++) {
        SocketChannel channel = server.accept();
        if (channel==null) return;

        channel.configureBlocking(false);
        channel.socket().setTcpNoDelay(tcpNoDelay);
        SelectionKey readKey = channel.register(selector, SelectionKey.OP_READ);
        c = new Connection(readKey, channel, System.currentTimeMillis());
        readKey.attach(c);
        synchronized (connectionList) {
View Full Code Here


            ch.socket().setReuseAddress(true);
            if (localAddress != null) {
                ch.socket().bind(localAddress);
            }

            ch.configureBlocking(false);

            if (ch.connect(address)) {
                DefaultConnectFuture future = new DefaultConnectFuture();
                newSession(ch, handler, config, future);
                success = true;
View Full Code Here

            if (session == null)
                break;

            SocketChannel ch = session.getChannel();
            try {
                ch.configureBlocking(false);
                session.setSelectionKey(ch.register(selector,
                        SelectionKey.OP_READ, session));

                // AbstractIoFilterChain.CONNECT_FUTURE is cleared inside here
                // in AbstractIoFilterChain.fireSessionOpened().
View Full Code Here

                socketChannel = SocketChannel.open();
            } catch (final IOException ex) {
                throw new IOReactorException("Failure opening socket", ex);
            }
            try {
                socketChannel.configureBlocking(false);
                validateAddress(request.getLocalAddress());
                validateAddress(request.getRemoteAddress());

                if (request.getLocalAddress() != null) {
                    final Socket sock = socketChannel.socket();
View Full Code Here

   
    void doAccept(SelectionKey key) throws IOException,  OutOfMemoryError {
      Connection c = null;
      ServerSocketChannel server = (ServerSocketChannel) key.channel();
      SocketChannel channel = server.accept();
      channel.configureBlocking(false);
      channel.socket().setTcpNoDelay(tcpNoDelay);
      SelectionKey readKey = channel.register(selector, SelectionKey.OP_READ);
      c = new Connection(readKey, channel, System.currentTimeMillis());
      readKey.attach(c);
      synchronized (connectionList) {
View Full Code Here

                break;

            SocketChannel ch = session.getChannel();
            try
            {
                ch.configureBlocking( false );
                session.setSelectionKey( ch.register( selector,
                                                      SelectionKey.OP_READ,
                                                      session ) );

                // AbstractIoFilterChain.CONNECT_FUTURE is cleared inside here
View Full Code Here

            if( localAddress != null )
            {
                ch.socket().bind( localAddress );
            }

            ch.configureBlocking( false );

            if( ch.connect( address ) )
            {
                DefaultConnectFuture future = new DefaultConnectFuture();
                newSession( ch, handler, config, future );
View Full Code Here

  protected final void doAccept() throws Exception
  {
    SocketChannel sc = channel().accept();
    try
    {
      sc.configureBlocking( false );
      acceptedChannel( sc );
    }
    catch ( EOFException e )
    {
      sc.close();
View Full Code Here

   */
  public StreamHandler newStreamHandler( InetSocketAddress addr,
    StreamHandlerFactory factory ) throws Exception
  {
    SocketChannel sc = SocketChannel.open();
    sc.configureBlocking( false );
    StreamHandler sh = factory.newStreamHandler( sc, true );
    register( sh );
    sc.connect( addr );
    return sh;
  }
View Full Code Here

            SocketChannel channel;
            SelectionKey key;
            try {
                channel = entry.getChannel();
                channel.configureBlocking(false);
                key = channel.register(this.selector, SelectionKey.OP_READ);
            } catch (final ClosedChannelException ex) {
                final SessionRequestImpl sessionRequest = entry.getSessionRequest();
                if (sessionRequest != null) {
                    sessionRequest.failed(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.