I am trying to do this C#. I need to find all ip address that are active in my network and show them in a list. I can ping all available (1...255) ip address in a network. But I want to make this process faster.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Please refer to This link about Asynchronous Client Socket to learn how to ping faster.
Edit: A quick snippet on how to accomplish this:
Taken from this Microsoft documentation.
http://www.advanced-ip-scanner.com/. this a tool you can use to see what ip's are active on your network. also what type of network hardware that PC uses.
if you want to go the ARP route, you can simply send out ARP requests for all adresses, wait a bit, and look into the ARP table of your host
this may help
http://www.codeguru.com/cpp/i-n/internet/internetprotocolip/article.php/c6153/How-to-Get-an-ARP-Table-with-an-IP-Helper-API.htm
This code scans my network 255 D-class segments in about 1 sec. I wrote it in VB.net and translated it to C# (apologies if there are any errors). Paste it into a Console project and run. Modify as needed.
Note: The code is not production ready and need improvements on especially the instance counting (try implement a
TaskFactory
with aBlockingCollection
instead).Modify ttl (time-to-live) and timeout if unstable result-wise.
Running the code will give a result like this:
C# code:
And VB.net code: