I wanted to use C#\'s UdpClient to listen to any incomming UDP packets. I want to receive packets from any IP and any port.
I tried the following:
Ud
Your best idea would be to identify specific ports you would like to listen to, and start listening on those. Depending on what is done with received datagrams, it might be best/simplest to create a new Thread
for each port you are listening on, and process it there, or enqueue it on a synchonrised (with lock
) queue or list, for processing on a central thread.
You should limit the ports though; it would not be possible to listen to them all.
That said you could use something like Wireshark
or the Winpcap
SDK/API to 'sniff' UDP packets right from the network adapter. I have had it working within a .NET application before without too much difficulty.
Hope that helps.