How to get IP of server automatically??

1 view
Skip to first unread message

Pawan

unread,
Jan 30, 2008, 5:43:28 AM1/30/08
to Java @ SCIT
I am building a online chat application. i have made the server
program in java using socket and server socket programming.

i have to retrieve the server address automanitically when i run the
clientcode can that be possible.. the clientcode will have to interact
with the server and would need it IP address. but if the server is
unknown how can i do that....

PLz reply as soon as possible thanking u

Pawan kumar meena
SDM 2007-09
SCIT

Sanket Daru

unread,
Jan 30, 2008, 7:04:27 AM1/30/08
to scit...@googlegroups.com
Hi Pawan,
This is a typical problem that we face when building Client-Server based applications. There needs to be at least one static server which can help the client to resolve the end-server address. Typically in a WebServices scenario, this problem is handled by publishing your service to a central repository from where it is resolved by the client. If you are using RMI, you must be aware about the "Binding the server to RMI registry". The client "looks-up" for the server address in this registry and then invokes various operations on it.

With your issue, as far as my knowledge goes, you need to have the server as a static server. To overcome the DHCP assigning a different address to the server, you can make a DNS lookup for the "server name" to get its IP which can then be used by your client.

Regards,
Sanket Daru.
Reply all
Reply to author
Forward
0 new messages