Package java.nio.channels

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


            sock.socket().setTcpNoDelay(true);
            setName(getName().replaceAll("\\(.*\\)",
                    "(" + addr.getHostName() + ":" + addr.getPort() + ")"));
            try {
                sockKey = sock.register(selector, SelectionKey.OP_CONNECT);
                boolean immediateConnect = sock.connect(addr);
                if (immediateConnect) {
                    primeConnection(sockKey);
                }
            } catch (IOException e) {
                LOG.error("Unable to open socket to " + addr);
View Full Code Here


                sch = SocketChannel.open();
                sch.configureBlocking(true);
                sch.socket().setSoTimeout(5000);

                InetSocketAddress addr = new InetSocketAddress(ipAddress, port);
                sch.connect(addr);
                return null;
            } catch (IOException e) {
                s_logger.info("Could not connect to " + ipAddress + " due to " + e.toString());
                if (e instanceof ConnectException) {
                    // if connection is refused because of VM is being started,
View Full Code Here

    for(SocketAddress sa : a) {
      SocketChannel ch=SocketChannel.open();
      ch.configureBlocking(false);
      MemcachedNode qa=f.createMemcachedNode(sa, ch, bufSize);
      int ops=0;
      if(ch.connect(sa)) {
        getLogger().info("Connected to %s immediately", qa);
        qa.connected();
        assert ch.isConnected();
      } else {
        getLogger().info("Added %s to connect queue", qa);
View Full Code Here

      i.remove();
      getLogger().info("Reconnecting %s", qa);
      SocketChannel ch=SocketChannel.open();
      ch.configureBlocking(false);
      int ops=0;
      if(ch.connect(qa.getSocketAddress())) {
        getLogger().info("Immediately reconnected to %s", qa);
        assert ch.isConnected();
      } else {
        ops=SelectionKey.OP_CONNECT;
      }
View Full Code Here

                ch.socket().bind(localAddress);
            }

            ch.configureBlocking(false);

            if (ch.connect(address)) {
                DefaultConnectFuture future = new DefaultConnectFuture();
                newSession(ch, handler, config, future);
                success = true;
                return future;
            }
View Full Code Here

                ch.socket().bind( localAddress );
            }
   
            ch.configureBlocking( false );

            if( ch.connect( address ) )
            {
                SocketSession session = newSession( ch, handler );
                success = true;
                return session;
            }
View Full Code Here

                sch = SocketChannel.open();
                sch.configureBlocking(true);
                sch.socket().setSoTimeout(5000);

                InetSocketAddress addr = new InetSocketAddress(targetIp, mshost.getServicePort());
                sch.connect(addr);
                return true;
            } catch (IOException e) {
                if (e instanceof ConnectException) {
                    s_logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " due to ConnectException", e);
                  return false;
View Full Code Here

                }
                sch = SocketChannel.open();
                sch.configureBlocking(true);

                final InetSocketAddress addr = new InetSocketAddress(ipAddress, port);
                sch.connect(addr);
                return null;
            } catch (final IOException e) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Could not connect to " + ipAddress);
                }
View Full Code Here

                }
                sch = SocketChannel.open();
                sch.configureBlocking(true);

                final InetSocketAddress addr = new InetSocketAddress(ipAddress, _port);
                sch.connect(addr);
                return true;
            } catch (final IOException e) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Could not connect to " + ipAddress);
                }
View Full Code Here

                sch = SocketChannel.open();
                sch.configureBlocking(true);
                sch.socket().setSoTimeout(5000);

                InetSocketAddress addr = new InetSocketAddress(ipAddress, port);
                sch.connect(addr);
                return null;
            } catch (IOException e) {
                s_logger.info("Could not connect to " + ipAddress + " due to " + e.toString());
                if (e instanceof ConnectException) {
                    // if connection is refused because of VM is being started,
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.