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
Joined: Dec 29, 2004
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.
Joined: Feb 03, 2005
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
Author and all-around good cowpoke
Joined: Mar 22, 2000
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 ]
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.