Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I plan to write an network application whose use steps is the following :

  1. Connect to the server and choose a name (and enter your email "id")
  2. The list of others "free" (not playing a game) players is shown to you : so you have to select one.
  3. The server use the two players ip adress in order to connect them

But I think I will be facing a great issue :

  • how to handle dynamic ip adress carefully : can a dynamic ip adress change while the established connection is not yet finished ?
  • if yes, how must I handle that, let's with Java 7 for example ?


share|improve this question
up vote 2 down vote accepted

Once someone has been assigned an IP it will not change until they log off (basically). So yes it can - in between getting a list of users and selecting one to play with, the person on the other end might disconnect, or be disconnected, or log off, or suffer a power cut or any other reason why they may no longer be available to play.

So you simply need to ensure that the person selected is still available when selected, so just attempt a connection and handle failures. The IP address will not change between the discovery and selection process so you don't need to worry about making connections to some random person, not unless the time between the 2 steps is very long.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.