Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: Rexima on September 18, 2016, 12:24:35 PM

Title: Add to externalAddress the UDP Port to Ping Gameserver?
Post by: Rexima on September 18, 2016, 12:24:35 PM
Hi,

i just had an problem to ping Gameserver.
So, i took a deeper look, and the externalAddress has the TCP Port. Take a look on my example below.

Is it possible to add an variable more with the UDP port?
For example
  1. ent.externalAddress.UDPPort

  1. TNet.List<ServerList.Entry> list = TNLobbyClient.knownServers.list;
  2.  
  3.         for (int i = 0; i < list.size; ++i)
  4.         {
  5.             ServerList.Entry ent = list[i];
  6.  
  7.             Debug.Log(ent.externalAddress); // IP:TCP PORT
  8.  
  9.             TNManager.Ping(Tools.ResolveEndPoint(ent.externalAddress.Address.ToString(), ent.externalAddress.Port+1), OnPing);
  10.         }
  11.  

The Ping works now, but if you could add this little thing, this would be very helpfull.
Title: Re: Add to externalAddress the UDP Port to Ping Gameserver?
Post by: ArenMook on September 18, 2016, 07:40:58 PM
The "externalAddress" is a system type (IPEndPoint). It's not a TNet type, so no, it's not possible to add anything to it. You're the one coding your game, so you should have some kind of a system for ports, for example your +1 convention. Ie: if you're choosing to listen to TCP port 5100, assume UDP is going to be 5101.

That, or just have the UDP port be available as a part of your server's name. For example:
  1. My Awesome Server|5101
You can easily do a string.Split("|") on that to get your two parts, then int.TryParse(part[1], out port) to get your port.
Title: Re: Add to externalAddress the UDP Port to Ping Gameserver?
Post by: Rexima on September 19, 2016, 01:51:02 AM
Aaaah, okay thanks  :)