Question by
MartinSeptim · Jun 21, 2016 at 06:06 PM ·
networkingnetworkip
How to get IP addresses of all devices in local network?
I have a lot of devices in one local network. How can I get ip addresses of all these devices?
Comment
Answer by Ejpj123 · Jun 21, 2016 at 07:04 PM
@MartinSeptim Try This:
using UnityEngine;
using System.Net;
using System.Net.Sockets;
public string LocalIPAddress()
{
IPHostEntry host;
string localIP = "";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip.ToString();
break;
}
}
return localIP;
}
This is equal to: string IP = Network.player.ipAddress;, but I want to create lobby, where people can connect to a server without hardcoded IP or typing IP by themself. Is it real?
Your answer