1.9.6 has this code built-in, and I tested the pinging using this script:
using UnityEngine;
using System.IO;
using TNet;
using System.Net;
public class Test : MonoBehaviour
{
string text = "";
void Start ()
{
text = "UDP: " + TNManager.StartUDP(Random.Range(10000, 50000));
}
void Update ()
{
if (Input.GetKeyDown(KeyCode.P))
{
TNManager.Ping(Tools.ResolveEndPoint("127.0.0.1", 5129), OnPing);
}
}
void OnPing (IPEndPoint ip, int ms)
{
text += "\nPing: " + ms;
}
void OnGUI ()
{
GUILayout.Label(text);
}
}
I just start the server via the executable, attach this script to some game object, hit Play and press "P".