views:

46

answers:

1

My program needs to listen incoming socket connections (lets agree on port 8765), but it doesn't know which addresses it can bind on a particular machine. Of, course, it could simply to listen to all of them, but it need to send to the client program over a different(slower) channel the addresses which it should try in order to rich me on port 8765.

So the flow is like this:

  1. My program lisens on all available interfaces on port 8765
  2. Finds out a list of inet4 adresses by which it can be possibly reached (this step is the actual question)
  3. Posts that address on a whiteboard (blogpost or something)
  4. Interested clients try out all of them, to see using which one they can reach my program.

This is all is to be done in java ofcourse :)

+2  A: 

NetworkInterface.getNetworkInterfaces()

Anon