Ended up using the following code to detect: network, internet and port
I'll try/catch when executing the server start function
Any optimization or feedback welcome...
//Note: For LAN use
using System.Linq;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using TNet;
using UnityEngine;
//http://www.c-sharpcorner.com/uploadfile/nipuntomar/check-internet-connection/
public class InternetCS
{
//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
//Creating a function that uses the API function...
public static bool IsConnectedToInternet()
{
int Desc;
return InternetGetConnectedState(out Desc, 0);
}
}
public bool isNetworkAvailable
{
get
{
return System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
}
}
public bool isInternetAvailable
{
get
{
return InternetCS.IsConnectedToInternet();
}
}
public bool isPortAvailable
{
get
{
ServerList.Entry[] list = TNLobbyClient.knownServers.list.ToArray();
if (list.FirstOrDefault(i => i.internalAddress.Port == serverTcpPort) == null) return true;
else return false;
}
}