Examples of channel()


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

                while (it.hasNext()) {
                    SelectionKey key = (SelectionKey) it.next();
                    // Is a new connection coming in?
                    if (key.isAcceptable()) {
                        ServerSocketChannel server =
                            (ServerSocketChannel) key.channel();
                        SocketChannel channel = server.accept();
                        registerChannel(selector,
                                        channel,
                                        SelectionKey.OP_READ,
                                        new ObjectReader(channel, selector,
View Full Code Here

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

            calls = new ArrayList<Call>(writeSelector.keys().size());
            iter = writeSelector.keys().iterator();
            while (iter.hasNext()) {
              SelectionKey key = iter.next();
              Call call = (Call)key.attachment();
              if (call != null && key.channel() == call.connection.channel) {
                calls.add(call);
              }
            }
          }
         
View Full Code Here

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

                attachment.close(new IOException("Connection closed"));

            // close the server socket
            } else if((key.interestOps() & SelectionKey.OP_ACCEPT) != 0) {
                try {
                    ServerSocketChannel server = (ServerSocketChannel)key.channel();
                    server.close();
                    key.cancel();
                } catch(IOException e) {
                    logger.warning("Error closing server socket, " + e.getMessage());
                }
View Full Code Here

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

  @Override
  public ServerContext createContext(TProtocol input, TProtocol output, Object selectionKeyObject) {
    LOG.debug("Client connected");
    SelectionKey selectionKey = (SelectionKey) selectionKeyObject;
    SocketChannel channel = (SocketChannel) selectionKey.channel();
    Socket socket = channel.socket();
    SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
    SocketAddress localSocketAddress = socket.getLocalSocketAddress();
    _connectionMeter.mark();
    _connections.incrementAndGet();
View Full Code Here

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

  @Override
  public ServerContext createContext(TProtocol input, TProtocol output, Object selectionKeyObject) {
    LOG.debug("Client connected");
    SelectionKey selectionKey = (SelectionKey) selectionKeyObject;
    SocketChannel channel = (SocketChannel) selectionKey.channel();
    Socket socket = channel.socket();
    SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
    SocketAddress localSocketAddress = socket.getLocalSocketAddress();
    _connectionMeter.mark();
    _connections.incrementAndGet();
View Full Code Here

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

            calls = new ArrayList<Call>(writeSelector.keys().size());
            iter = writeSelector.keys().iterator();
            while (iter.hasNext()) {
              SelectionKey key = iter.next();
              Call call = (Call)key.attachment();
              if (call != null && key.channel() == call.connection.channel) {
                calls.add(call);
              }
            }
          }
View Full Code Here

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

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

        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

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

            calls = new ArrayList<Call>(writeSelector.keys().size());
            iter = writeSelector.keys().iterator();
            while (iter.hasNext()) {
              SelectionKey key = iter.next();
              Call call = (Call)key.attachment();
              if (call != null && key.channel() == call.connection.channel) {
                calls.add(call);
              }
            }
          }
         
View Full Code Here

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

            logger.trace("Reading from socket");
            readSocket(key);
          }
          if (key.isWritable()) {
            logger.trace("Writing data to socket");
            getContext(key, (SocketChannel) key.channel()).writeBufferToClient();
          }
          if (key.isAcceptable()) {
            SocketChannel client = acceptConnection();
            logger.trace("Accepted new connection from "+client.socket().getRemoteSocketAddress());
          }
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.