Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getiing Server IP address

 
Deepa Jayaprakash
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
How can i get server IP using java code?

Thanks
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need more info, does the server need it's own IP, or does a client need the server's IP?
 
Deepa Jayaprakash
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its client which wants server IP.
 
Jody Brown
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you use java.net.InetAddress.getAddress() to obtain it?
 
Paul Clapham
Sheriff
Posts: 21136
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the client already have a connection to the server? If it's a Socket connection then you'd just use the getInetAddress() method of the Socket class.

But if the question is "I have no idea what the IP address of the server is, how can I connect to it?" then the answer is something like "Ask the administrator of the server."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic