I am making a multiplayer game. One of the players plays as host and the other one connects as client. To connect you have to enter the IP and be on the same WIFI.
The problem is that while on PC it works fine on android doesn't. The problem is that you can join well if the server is made in PC but not if you do it on android, android can join to PC but not to other android. I think the problem is in the IP that I show.
Here is the code I use:
GetLocalIPAddress()
{
var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
return ip.ToString();
}
}
throw new System.Exception("No network adapters with an IPv4 address in the system!");
}