Package java.net

Examples of java.net.Socket.connect()


     
      try{
        Socket socket = new Socket();
     
        try{
          socket.connect( new InetSocketAddress( _address, 2190 ), 5000 );
         
          socket.setSoTimeout( 5000 );
 
          DataOutputStream dos = new DataOutputStream( socket.getOutputStream());
         
View Full Code Here


            try {
                if (ssl) {
                    return CipherFactory.createSocket(address, port);
                }
                Socket socket = new Socket();
                socket.connect(new InetSocketAddress(address, port),
                        SysProperties.SOCKET_CONNECT_TIMEOUT);
                return socket;
            } catch (IOException e) {
                if (System.currentTimeMillis() - start >= SysProperties.SOCKET_CONNECT_TIMEOUT) {
                    // either it was a connect timeout,
View Full Code Here

        Socket socket = null;
        final OutputStream out;
        try {
            channel = SocketChannel.open();
            socket = channel.socket();
            socket.connect(dstSockAddr);
            out = socket.getOutputStream();
        } catch (IOException e) {
            LOG.error("failed to connect: " + dstSockAddr, e);
            IOUtils.closeQuietly(channel);
            NetUtils.closeQuietly(socket);
View Full Code Here

        Socket socket = null;
        final OutputStream out;
        try {
            channel = SocketChannel.open();
            socket = channel.socket();
            socket.connect(dstSockAddr);
            out = socket.getOutputStream();
        } catch (IOException e) {
            LOG.error("failed to connect: " + dstSockAddr, e);
            IOUtils.closeQuietly(channel);
            NetUtils.closeQuietly(socket);
View Full Code Here

      Socket socket = socketfactory.createSocket();
      SocketAddress localaddr = new InetSocketAddress(localAddress,
          localPort);
      SocketAddress remoteaddr = new InetSocketAddress(host, port);
      socket.bind(localaddr);
      socket.connect(remoteaddr, timeout);
      return socket;
    }
  }

  /**
 
View Full Code Here

    /* Timeout is defined */
    Socket socket = socketfactory.createSocket();
    SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
    SocketAddress remoteaddr = new InetSocketAddress(host, port);
    socket.bind(localaddr);
    socket.connect(remoteaddr, timeout);
    return socket;
  }

  /*
   * @see java.lang.Object#equals(java.lang.Object)
View Full Code Here

        } else {
            Socket socket = socketfactory.createSocket();
            SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
            SocketAddress remoteaddr = new InetSocketAddress(host, port);
            socket.bind(localaddr);
            socket.connect(remoteaddr, timeout);
            return socket;
        }
    }

    /**
 
View Full Code Here

            int timeout = 5000; // 5 seconds
            if (log.isInfoEnabled())
              log.info("Connecting to " + bindAddress + ":" + port + " to see if a server is already running.");
            SocketAddress socketAddress = new InetSocketAddress(bindAddress, port);
            socket = new Socket();
            socket.connect(socketAddress, timeout);
            locked = true;
        } catch (Exception e) {
            locked = false;
        } finally {
            if (socket != null) {
View Full Code Here

            public Boolean call() {
                //long time = System.currentTimeMillis();
                try {
                    final Socket socket = new Socket();
                    //System.out.println("PING socket create = " + (System.currentTimeMillis() - time) + " ms (" + host + ":" + port + ")"); time = System.currentTimeMillis();
                    socket.connect(new InetSocketAddress(host, port), timeout);
                    //System.out.println("PING socket connect = " + (System.currentTimeMillis() - time) + " ms (" + host + ":" + port + ")"); time = System.currentTimeMillis();
                    if (socket.isConnected()) {
                        socket.close();
                        return Boolean.TRUE;
                    }
View Full Code Here

            {
                InetSocketAddress addr = doPassiveSimple();
                if (addr != null)
                {
                    socket = new Socket();
                    socket.connect(addr, m_dataConTimeout);
                    socket.setSoTimeout(m_dataTimeout);
                }
            }
            catch(IOException ex)
            {}
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.