Package java.net

Examples of java.net.Socket.bind()


        SocketChannel channel = SocketChannel.open();
        Socket socket;
        boolean close = true;
        try {
            socket = channel.socket();
            socket.bind(local);

            connect(channel, remote);
            close = false;
        } finally {
            // Make sure that the channel is closed in the case of an error.
View Full Code Here


  {
    //open connection to the print server
    Socket sock = new Socket();   
    try
    {
      sock.bind(null);
      sock.connect(new InetSocketAddress(hostname_, port_), timeoutMillis_);
    }
    catch (IOException ioe)
    {
      return false;
View Full Code Here

   
    //open connection to the print server
    Socket sock = new Socket();   
    try
    {
      sock.bind(null);
      sock.connect(new InetSocketAddress(hostname_, port_), timeoutMillis_);
    }
    catch (IOException ioe)
    {
      throw new RuntimeException("print: can not connect to remote print server " +
View Full Code Here

  {
    //open connection to the print server
    Socket sock = new Socket();   
    try
    {
      sock.bind(null);
      sock.connect(new InetSocketAddress(hostname_, LPD_LISTEN_PORT), timeoutMillis_);
    }
    catch (IOException ioe)
    {
      return false;
View Full Code Here

        // check that remote host is not accessible anymore
        // open a socket without any parameters. It hasn't been binded or connected
        Socket socket = new Socket();
        try {
            // bind to a local ephemeral port
            socket.bind(null);
            socket.connect(new InetSocketAddress(remoteHost, RLoginClient.DEFAULT_PORT), 1);
        } catch (SocketTimeoutException e) {
            logger.info("Rebooted host " + remoteHost + " successfully");
            return true;
        } catch (IOException e) {
View Full Code Here

          socket = sslfac.createSocket(host, port, localAddress, localPort);
        } else {
            socket = sslfac.createSocket();
            SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
            SocketAddress remoteaddr = new InetSocketAddress(host, port);
            socket.bind(localaddr);
            socket.connect(remoteaddr, timeout);
        }
        setSocket(socket);
        return wrapSocket(socket);
    }
View Full Code Here

            return socketfactory.createSocket(host, port, localAddress, localPort);
        } 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

    {
        Socket socket = socketFactory.createSocket();
        SocketAddress local = new InetSocketAddress(localAddress, localPort);
        SocketAddress remote = new InetSocketAddress(host, port);
       
        socket.bind(local);
        socket.connect(remote, timeout);
        return socket;
    }
}
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

            final HttpContext context) throws IOException, ConnectTimeoutException {
        Args.notNull(host, "HTTP host");
        Args.notNull(remoteAddress, "Remote address");
        Socket sock = socket != null ? socket : createSocket(context);
        if (localAddress != null) {
            sock.bind(localAddress);
        }
        try {
            sock.connect(remoteAddress, connectTimeout);
        } catch (final SocketTimeoutException ex) {
            throw new ConnectTimeoutException(host, remoteAddress);
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.