Examples of validOps()


Examples of java.nio.channels.DatagramChannel.validOps()

                    }

                    synchronized(selector) {
                      selector.wakeup();
                      try {
                        newDatagramChannel.register(selector, newDatagramChannel.validOps());
                      } catch (ClosedChannelException e1) {
                        logger.error("An exception occurred while registering a selector: {}",e1.getMessage());
                      }
                    }
View Full Code Here

Examples of java.nio.channels.SelectableChannel.validOps()

    public void Add(Socket x)
    {
        SelectableChannel ch = x.GetChannel();
        try
        {
            SelectionKey key = ch.register( m_selector, ch.validOps(), x);
            x.SetKey(key);
            x.OnInitialOps();
            m_sockets.add(x);
            PrintSockets();
        } catch (Exception e)
View Full Code Here

Examples of java.nio.channels.SelectableChannel.validOps()

        SelectableChannel[] channels = handler.getChannels();
        try {
            for (int i = 0; i < channels.length; i++) {
                SelectableChannel channel = channels[i];
                channel.configureBlocking(false);
                int validOps = channel.validOps();
                // It's a bug of java nio, see:
                // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4960791
                boolean isConnected = (validOps & SelectionKey.OP_CONNECT) != 0
                        && ((SocketChannel) channel).isConnected();
                channel.register(selector, isConnected ? SelectionKey.OP_READ
View Full Code Here

Examples of java.nio.channels.SelectableChannel.validOps()

        for (int i = 0; i < channels.length; i++) {
            SelectableChannel channel = channels[i];
            SelectionKey key = channel.keyFor(selector);
            if (key != null)
                key.interestOps(key.interestOps()
                        | (channel.validOps() & interest.ops));
        }
    }

    private void changeDeregister(ReactorHandler handler) {
        if (registered.remove(handler) != null)
View Full Code Here

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

              BINKD_PORT, 24554));
      server.bind(bind, 5);
      logger.l1("We are listening on " + bind.getHostString() + ":"
          + bind.getPort());
      Selector selector = Selector.open();
      server.register(selector, server.validOps());
      while (true) {
        selector.select();
        for (SelectionKey key : selector.selectedKeys()) {
          try {
            ServerSocketChannel channel = (ServerSocketChannel) key
View Full Code Here

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

  {
    ServerSocketChannel selectable = ServerSocketChannel.open();
    selectable.configureBlocking(false);

    selectable.socket().bind(address == null ? new InetSocketAddress(tcpPort) : new InetSocketAddress(address, tcpPort));
    selectable.register(getSelector(), selectable.validOps());
    setName("SelectorThread:" + selectable.socket().getLocalPort());
  }

  protected ByteBuffer getPooledBuffer()
  {
View Full Code Here

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

  {
    selector = Selector.open();
    ServerSocketChannel selectable = ServerSocketChannel.open();
    selectable.configureBlocking(false);
    selectable.socket().bind(address == null ? new InetSocketAddress(tcpPort) : new InetSocketAddress(address, tcpPort));
    selectable.register(selector, selectable.validOps());
  }
 
  /**
   * Method run.
   * @see java.lang.Runnable#run()
View Full Code Here

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

  {
    ServerSocketChannel selectable = ServerSocketChannel.open();
    selectable.configureBlocking(false);
   
    selectable.socket().bind(address == null ? new InetSocketAddress(tcpPort) : new InetSocketAddress(address, tcpPort));
    selectable.register(getSelector(), selectable.validOps());
    setName("SelectorThread:" + selectable.socket().getLocalPort());
  }
 
  /**
   * Method getPooledBuffer.
View Full Code Here

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

    @Override
    void accept (ServerSocketChannel server, Selector selector) throws IOException {
        SocketChannel channel = server.accept ();
        channel.configureBlocking (false);
       
        int validOps = channel.validOps ();
        System.out.println (validOps);
       
        if (! checkEligibility (channel)) {
            channel.finishConnect ();
            selector.close ();
View Full Code Here

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

        try {
          s = SocketChannel.open();
          s.configureBlocking(false);
          // now this method is non-blocking
          s.connect(server);
          key = s.register(selector, s.validOps());
          // attach index of the key
          key.attach(i);
        } catch (Exception e) {
          stats.incNumConnectErrorServers()
          String err = String.format("set up socket to server %s error: %s",
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.