Package java.nio.channels

Examples of java.nio.channels.SelectionKey.channel()


            if (session == null)
                break;
            else {
                SelectionKey key = session.getSelectionKey();
                DatagramChannel ch = (DatagramChannel) key.channel();
                try {
                    ch.disconnect();
                    ch.close();
                } catch (IOException e) {
                    ExceptionMonitor.getInstance().exceptionCaught(e);
View Full Code Here


                if (!key.isAcceptable()) {
                    continue;
                }

                ServerSocketChannel ssc = (ServerSocketChannel) key.channel();

                SocketChannel ch = ssc.accept();

                if (ch == null) {
                    continue;
View Full Code Here

        Iterator<SelectionKey> it = keys.iterator();
        while (it.hasNext()) {
            SelectionKey key = it.next();
            it.remove();

            DatagramChannel ch = (DatagramChannel) key.channel();

            RegistrationRequest req = (RegistrationRequest) key.attachment();
            try {
                if (key.isReadable()) {
                    readSession(ch, req);
View Full Code Here

            if( session == null )
                break;
            else
            {
                SelectionKey key = session.getSelectionKey();
                DatagramChannel ch = ( DatagramChannel ) key.channel();
                try
                {
                    ch.disconnect();
                    ch.close();
                }
View Full Code Here

        while( it.hasNext() )
        {
            SelectionKey key = ( SelectionKey ) it.next();
            it.remove();

            DatagramChannel ch = ( DatagramChannel ) key.channel();

            RegistrationRequest req = ( RegistrationRequest ) key.attachment();
            DatagramSession session = new DatagramSession(
                    filters, ch, req.handler );
            session.setSelectionKey( key );
View Full Code Here

                if( !key.isAcceptable() )
                {
                    continue;
                }
  
                ServerSocketChannel ssc = ( ServerSocketChannel ) key.channel();
  
                SocketChannel ch = ssc.accept();
  
                if( ch == null )
                {
View Full Code Here

            SelectionKey key = ( SelectionKey ) it.next();

            if( !key.isConnectable() )
                continue;

            SocketChannel ch = ( SocketChannel ) key.channel();
            ConnectionRequest entry = ( ConnectionRequest ) key.attachment();

            try
            {
                ch.finishConnect();
View Full Code Here

                    entry.notify();
                }

                try
                {
                    key.channel().close();
                }
                catch( IOException e )
                {
                    exceptionMonitor.exceptionCaught( this, e );
                }
View Full Code Here

                        // full list of known addresses, followed by the "end"
                        // address to signal that we are done.

                        // Afterward we will only pulls our heartbeat

                        ServerSocketChannel server = (ServerSocketChannel) key.channel();
                        SocketChannel client = server.accept();
                        InetSocketAddress address = (InetSocketAddress) client.socket().getRemoteSocketAddress();

                        client.configureBlocking(false);
View Full Code Here

      } else {
    // Ok, something is very bad here, try to shutdown the channel
    // and hope that we handle it ok elsewhere...
    logger.logError ("Bad handler for:" + sk + ": " + a);
    sk.cancel ();
    sk.channel ().close ();
      }
  }
  selected.clear ();
    }
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.