aspose file tools*
The moose likes Distributed Java and the fly likes How to get server IP address from Client?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "How to get server IP address from Client??" Watch "How to get server IP address from Client??" New topic
Author

How to get server IP address from Client??

Siddharth Ramavat
Ranch Hand

Joined: Feb 03, 2005
Posts: 41
Hello all,

I am making an chat application. Actually, most of the part has been completed successfully. The main problem that I am facing right now is that each and evertime when I load my client I have to specify the server's name or it's IP address for URL Connection. One of the biggest limitation of my application occurs here.

When I changed my application from one LAN to another LAN I have to specify it's servers's IP address.... so my application become hard-code here..

So, I want to know that is there any way to get directly server's name or it's IP when my client loads.... It doesn't matter that it has been changed to another network or not....??


Waiting for your reply...

Thank You,
Siddharth
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
There are a couple of options.

1) Scan all IP addresses - takes a long time.

2) If you know it will be on a local network scan all local IP's

3) Force the user to select or enter a server.

4) Use a Multicast socket for the server to listen on, have the client fire off a request on the multicast IP, the server can send it's actual IP in the response. - May not work with certain routers.

5) Look into JXTA, not sure if that will help, not very familiar with it.
Siddharth Ramavat
Ranch Hand

Joined: Feb 03, 2005
Posts: 41
Hello Sir,

Thanks for the reply.

Sir i would like to ask that if I use either of the first two alternatives provided by you, then how to scan for the IP's & which method or API will be useful to me.

Thanking you,
Siddharth
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Forming connections on networks where the location of servers and clients changes is the kind of thing JINI was made for. See the JINI web site for more.
Bill
[ May 06, 2005: Message edited by: William Brogden ]
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
I don't know that I would necessarily recommend JINI in this case, as it is a lot of overhead (starting all of the services). But, you're right, JINI technology handles cases like this very well and I would recommend maybe borrowing some ideas from JINI. I would read up on the JINI discovery mechanism(s). Steven Bell already alluded to a similar solution in his #4 suggestion.


James Carman, President<br />Carman Consulting, Inc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get server IP address from Client??