Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public async Task Ping(int lowLim, int uppLim)
  2. {
  3. string[] ipParts = GetCurrentIPAddress().Split('.');
  4. for (int i = lowLim; i <= uppLim; i++)
  5. {
  6. IterEvent.Invoke(i);
  7. PingReply answer = await AsincPing(string.Format("{0}.{1}.{2}.{3}", ipParts[0], ipParts[1], ipParts[2], i.ToString()));
  8. string macAddress = await GetMACAddress(answer.Address);
  9. try
  10. {
  11. if (answer.Status == IPStatus.Success)
  12. {
  13. PingEvent.Invoke(answer.Address.ToString() + "|" + macAddress + "|" + answer.RoundtripTime +
  14. "|" + Dns.GetHostEntry(answer.Address.ToString()).HostName);
  15. }
  16. }
  17. catch
  18. {
  19. PingEvent.Invoke(answer.Address.ToString() + "|" + macAddress + "|" + answer.RoundtripTime + "|" + ".....");
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement