Friday, 15 February 2008

Get Ip address in Java

getInetAddress

public InetAddress getInetAddress()

Returns the address to which the socket is connected.

Returns:
the remote IP address to which this socket is connected, or null if the socket is not connected.



getLocalAddress

public InetAddress getLocalAddress()

Gets the local address to which the socket is bound.

Returns:
the local address to which the socket is bound or InetAddress.anyLocalAddress() if the socket is not bound yet.
Since:
JDK1.1


No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter