Question by
Kusakari13 · Dec 03, 2016 at 09:35 AM ·
network
Ping isDone allways false
I want to know which ips are used in my home network. To achieve that i create a ping for every possible ip in my home network and store them in a list.
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
string ipAddress = Array.Find<IPAddress>(ipHostInfo.AddressList, ipMatch => ipMatch.AddressFamily == AddressFamily.InterNetwork).ToString();
string[] ipParts = ipAddress.Split('.');
for (int i = 3; i < 255; i++)
{
string tempIp = string.Format("{0}.{1}.{2}.{3}", ipParts[0],ipParts[1],ipParts[2], i.ToString());
TotalPings.Add(new Ping(tempIp));
}
After that i tried to wait until all pings are done
private bool PingsDone()
{
foreach (var ping in TotalPings)
{
if (!ping.isDone)
{
return false;
}
}
return true;
}
But my pings mostly never reach that state. I had one ping return true once in a few tries, the one for my own ip. Since then i dont have any pings returning true, i tried pinging google, isDone is false even after like 10 seconds of wait time.
What am i doing wrong, why do i get an isDone in very rare occasions ?
Comment
Your answer
Follow this Question
Related Questions
NullReferenceException 0 Answers
Catch/ignore NetworkManager.StartHost error 0 Answers
Only Host Can Damage Players In A Network Match 0 Answers
Lerping to Smooth Network Movement 0 Answers