Search code examples
javasocketsip-addressdynamic-ip

Socket for dynamic IP Address


I'm creating a client/server application that should work on LAN.

First with RMI the user register their I don't know what (IP?), this is the question :)

After that I create a ServerSocket and wait for accept().

Now the client (or better, the server...that have the registered user) want to establish a connection but... what if the IP Address was changed ?

There is a way to "register something" on the server that if the IP change all continue working?

I try to explain it better: I can't register an IP address and later connect on it, because if the IP change I lost the reference. I would like to register "something" that is independent from the IP.

Hope you have understand my question...


Solution

  • The answer is to use DNS. DNS is the appropriate de-referencing mechanism to obtain one or more IP addresses for a given name.