Package java.nio.channels

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


                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


                        key, callbackHandler));

                boolean isConnected;

                try {
                    isConnected = socketChannel.connect(remoteAddress);
                } catch (Exception e) {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE,
                                "Exception occured when tried to connect socket",
                                e.getMessage());
View Full Code Here

                            key, callbackHandler));

                    boolean isConnected;

                    try {
                        isConnected = socketChannel.connect(remoteAddress);
                    } catch (Exception e) {
                        if (logger.isLoggable(Level.FINE)) {
                            logger.log(Level.FINE,
                                    "Exception occured when tried to connect socket",
                                    e.getMessage());
View Full Code Here

          SocketUtils.setupSocket(socketChannel.socket(),
                              socketSendBufferSize,
                              socketRecvBufferSize);
                   
            log.debug("#"+id+" opening a TCP connection to "+host+":"+port);
            socketChannel.connect(new InetSocketAddress(host,port));
           
            return socketChannel;
        }
        catch (Exception e)
        {
View Full Code Here

      }
    }
    // Must make a fresh socket
    SocketChannel sock2 = SocketChannel.open();
    sock2.socket().setSendBufferSize(AutoBuffer.BBSIZE);
    boolean res = sock2.connect( _key );
    assert res && !sock2.isConnectionPending() && sock2.isBlocking() && sock2.isConnected() && sock2.isOpen();
    TCPS.incrementAndGet();     // Cluster-wide counting
    return sock2;
  }
  synchronized void freeTCPSocket( SocketChannel sock ) {
View Full Code Here

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

            if( ch.connect( address ) )
            {
                SocketSessionImpl session = newSession( ch, handler, config );
                success = true;
                ConnectFuture future = new ConnectFuture();
                future.setSession( session );
View Full Code Here

    super(protocolAddress);
    SocketChannel socket = SocketChannel.open();
    try {
      String[] parts = protocolAddress.split(":");
      if (parts.length == 1) {
        socket.connect(new InetSocketAddress(protocolAddress, 24554));
      } else if (parts.length == 2) {
        int port = Integer.valueOf(parts[1]);
        socket.connect(new InetSocketAddress(parts[0], port));
      } else {
        throw new IOException("Invalid protocolAddress ("
View Full Code Here

      String[] parts = protocolAddress.split(":");
      if (parts.length == 1) {
        socket.connect(new InetSocketAddress(protocolAddress, 24554));
      } else if (parts.length == 2) {
        int port = Integer.valueOf(parts[1]);
        socket.connect(new InetSocketAddress(parts[0], port));
      } else {
        throw new IOException("Invalid protocolAddress ("
            + protocolAddress + ") for this scheme");
      }
    } catch (NumberFormatException e) {
View Full Code Here

            sc = SocketChannel.open();
            sc.configureBlocking(true);
            sc.socket().setSoLinger(false, -1);
            sc.socket().setTcpNoDelay(true);

            boolean connected = sc.connect(remote);
            if (connected) {
                sc.configureBlocking(false);
                Connection c = new Connection(sc, this.clientRPCProcessor, null);
                this.connectionList.add(c);
            }
View Full Code Here

  {
    SocketChannel sc = SocketChannel.open();
    sc.configureBlocking( false );
    StreamHandler sh = factory.newStreamHandler( sc, true );
    register( sh );
    sc.connect( addr );
    return sh;
  }

  /**
   * @param sc
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.