Package java.nio.channels

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


        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

        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

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.