Skip to main content

How can I get the client's IP?

2 replies [Last post]
zobin
Offline
Joined: 2009-06-14

I run the DiscoveryServer application(the code of DiscoveryServer in tutorials directory)
when the client connect the server,console display message like this:
2009-6-14 18:02:33 net.jxta.impl.endpoint.tcp.TcpMessenger
信息: Creating new TCP Connection to : tcp://192.168.0.2:9768 / 192.168.0.2:9768

question:
how can i get the client's IP(192.168.0.2)?
and use System.out.println to display the client's IP in console ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
boylejohnr
Offline
Joined: 2008-10-27

Not sure why you need this - please give more detail.

JXTA is a network overlay, therefore IP Address in not exposed in the API for communication. And the IP you see is only the IP of a particular transport connection. This for instance could refer to a connection to a relay service and not the peer you are communicated with over pipes.

Therefore, using IP for anything is not a good idea.

zobin
Offline
Joined: 2009-06-14

Thank U for your help. I will try the other way to get the client information