Getting UdpListener properties at runtime

escjosh
edited February 2012 in Photon Server
Is there a way to access the UdpListener properties at runtime? I've got a PhotonApplication instance launching from PhotonConfig.config that has a UdpListener defined like so:
<UDPListener
				IPAddress="0.0.0.0"
				Port="5055">
      </UDPListener>

And I'd like to be able to determine at runtime which IP and port the server is bound to.

In other words, I want the server to find out what its own public address is (the one where players connect) so that it can tell the master server. (My master server works a little differently from the one distributed in the Loadbalancing project.)

I see that in the Loadbalancing demo, you make a WebRequest to whatismyip.com to find out what the public IP is. Is there really no other way?

Specifying the public IP in a config file isn't my first choice because we want to start and stop instances on EC2 with as little trouble as possible and it may not be possible to even know what the public IP will be until run time.

Comments

  • As far as I know, this problem has no simple solution.
    The Photon server can only start listening to addresses (ip:port) which are locally available on the machine. Most servers have more than one network interface and sometimes neither is a public address. So to find out the public address you need to config it (if you know it at all) or you have to ask someone "outside" which could be whatismyip.com.

    EC2 is a special case. They have their own way to identify a machine's public IP, so while using it, you should use their service/config.

    Im not sure if a game server's public address is also used when it connects to the master's public address.
  • Ok, that makes sense. Thanks, Tobias.