Author Topic: Ping a Game Server doesnt work?!  (Read 1941 times)

Rexima

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 78
    • View Profile
Ping a Game Server doesnt work?!
« on: September 07, 2016, 03:02:33 PM »
Hey,

i just upgraded to 3.0 and im happy to see what you have done so far, really nice.

But i have a question.
My Game Servers are registered to one Lobby Server.
The Client connects to the Lobby Server to retrieve all registered Game Servers.
And my plan is now, to connect to one server with the lowest latency.

But i cannot use TNManager.Ping(ip, callback) to check the latency of every server.
The error was something like, i need to be connected to one Game Server to make a Ping...

Im using now the build in Ping Command of Unity.

  1. Ping p = new Ping(ent.externalAddress.Address.ToString());
  2. while (!p.isDone) { }
  3. Debug.Log("tome: " + p.time);

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Ping a Game Server doesnt work?!
« Reply #1 on: September 07, 2016, 08:29:49 PM »
That error message is peculiar. Maybe something new to TNet3? TNet2 uses UDP for the TNManager.Ping function, so no connection necessary. Are you initializing UDP? I believe you need to add this somewhere:
  1. TNManager.StartUDP(Random.Range(10000, 50000));
  2.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Ping a Game Server doesnt work?!
« Reply #2 on: September 09, 2016, 03:01:11 PM »
Using Unity's Ping obviously won't work, as it has nothing to do with TNet. You should be using TNManager.Ping(...) instead.

The server needs to be listening to a UDP port in order to be able to respond to pings.