Proxy Address() Example

Started by VelMurugan, Dec 30, 2008, 11:36 PM

Previous topic - Next topic

VelMurugan

Proxy Address() Example

Returns the socket address of the proxy, or null if its a direct connection.

Proxyclass Address() method example. This example shows you how to use Address() method.This method Returns the socket address of the proxy, or null if its a direct connection.

Here is the code:-

/*
* @Program that Returns the socket address of the proxy, or null if its a
   direct connection.
* Address.java
* Author:-RoseIndia Team
* Date:-23-Jun-2008
*/

import java.net.*;

public class Address {

    public static void main(String[] args) {
        SocketAddress ss = new InetSocketAddress("girish-desktop", 8080);
        Proxy p = new Proxy(Proxy.Type.SOCKS, ss);
        // Returns the socket address of the proxy
        System.out.println("Socket address of the proxy is: "+p.address());
    }
}


Output of the program:-

Socket address of the proxy is: girish-desktop/127.0.1.1:8080


Source : codingdiary