Author Topic: Add to externalAddress the UDP Port to Ping Gameserver?  (Read 1759 times)

Rexima

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 78
    • View Profile
Add to externalAddress the UDP Port to Ping Gameserver?
« 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Add to externalAddress the UDP Port to Ping Gameserver?
« Reply #1 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.
« Last Edit: September 18, 2016, 07:47:05 PM by ArenMook »

Rexima

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 78
    • View Profile
Re: Add to externalAddress the UDP Port to Ping Gameserver?
« Reply #2 on: September 19, 2016, 01:51:02 AM »
Aaaah, okay thanks  :)