Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 ?

Regards

share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.