Package java.nio.channels

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


    }
  }

  private void processConnect(SelectionKey key) throws Exception {
    SocketChannel ch = (SocketChannel) key.channel();
    if (ch.finishConnect()) {
      LOG.info("connected to " + address+":"+port);
      key.interestOps(key.interestOps() ^ SelectionKey.OP_CONNECT);
      key.interestOps(key.interestOps() | SelectionKey.OP_READ);
      reconnectInterval = INITIAL_RECONNECT_INTERVAL;
      connected.set(true);
View Full Code Here


            if (key.isConnectable()) {

              // finish doing the connection

              sock = (SocketChannel) key.channel();
                                                        boolean result = sock.finishConnect();
              log("Finished Connecting "+result);
              poll = Selector.open();
              sock.register(poll, SelectionKey.OP_READ);
              connected = true;
              log("Initializing Handshake");
View Full Code Here

        // Why we just have to do this once, here
        updateNow();
        for (SelectionKey k : selected) {
            SocketChannel sc = ((SocketChannel) k.channel());
            if ((k.readyOps() & SelectionKey.OP_CONNECT) != 0) {
                if (sc.finishConnect()) {
                    updateLastSendAndHeard();
                    sendThread.primeConnection();
                }
            } else if ((k.readyOps() & (SelectionKey.OP_READ | SelectionKey.OP_WRITE)) != 0) {
                doIO(pendingQueue, outgoingQueue, cnxn);
View Full Code Here

    protected void connect(SelectionKey key) throws IOException {
        SocketChannel socketChannel = (SocketChannel)key.channel();

        try {
            socketChannel.finishConnect();
            key.interestOps(SelectionKey.OP_READ);
            Socket socket = socketChannel.socket();
            if (!socket.getKeepAlive()) {
                socket.setKeepAlive(true);
            }
View Full Code Here

                synchronized (socketChannel) {
                    if (socketChannel.isOpen()) {
                        ClientSocketChannelHandler clientSocketChannelHandler =
                                (ClientSocketChannelHandler) channelHandler;
                        try {
                            socketChannel.finishConnect();
                            clientSocketChannelHandler.connectSucceeded();
                            cachedInterestOps = SelectionKey.OP_READ;
                        } catch (IOException ex) {
                            cachedReadyOps = 0;
                            selectionKey.cancel();
View Full Code Here

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

            boolean success = false;
            try {
                if (ch.finishConnect()) {
                    key.cancel();
                    newSession(ch, entry.handler, entry.config, entry);
                }
                success = true;
            } catch (Throwable e) {
View Full Code Here

    protected void connect(SelectionKey key) throws IOException {
        SocketChannel socketChannel = (SocketChannel)key.channel();

        try {
            socketChannel.finishConnect();
            key.interestOps(SelectionKey.OP_READ);
            Socket socket = socketChannel.socket();
            if (!socket.getKeepAlive()) {
              socket.setKeepAlive(true);
            }
View Full Code Here

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

            try
            {
                ch.finishConnect();
                SocketSession session = newSession( ch, entry.handler );
                entry.session = session;
            }
            catch( Throwable e )
            {
View Full Code Here

                    // Why we just have to do this once, here
                    now = System.currentTimeMillis();
                    for (SelectionKey k : selected) {
                        SocketChannel sc = ((SocketChannel) k.channel());
                        if ((k.readyOps() & SelectionKey.OP_CONNECT) != 0) {
                            if (sc.finishConnect()) {
                                lastHeard = now;
                                lastSend = now;
                                primeConnection(k);
                                LOG.info("Server connection successful");
                            }
View Full Code Here

                SessionRequestHandle requestHandle = (SessionRequestHandle) key.attachment();
                SessionRequestImpl sessionRequest = requestHandle.getSessionRequest();

                // Finish connection process
                try {
                    channel.finishConnect();
                } catch (IOException ex) {
                    sessionRequest.failed(ex);
                }
                key.cancel();
                if (channel.isConnected()) {
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.