static List<UdpClient> CreateSockets()
{
List<UdpClient> clients = new List<UdpClient>();
try
{
foreach (NetworkInterface n in NetworkInterface.GetAllNetworkInterfaces())
{
foreach (UnicastIPAddressInformation address in n.GetIPProperties().UnicastAddresses)
{
if (address.Address.AddressFamily == AddressFamily.InterNetwork)
{
try
{
clients.Add(new UdpClient(new IPEndPoint(address.Address, 0)));
}
catch
{
continue; // Move on to the next address.
}
}
}
}
}
catch (Exception)
{
clients.Add(new UdpClient(0));
}
return clients;
}