How to receive UDP packets from any ip and any port?

That's insane. You would be flooded with messages from other applications (try TcpView for an idea of how many messages get passed on your system per second!).

That's insane. You would be flooded with messages from other applications (try TcpView for an idea of how many messages get passed on your system per second!) You must specify a port! Port is sort of like an identifier -- this packet is meant for THIS program (identified by port #) Send on any port is sensible, as it asks the system to choose a port send OUT port for you -- which isn't really that important to your application as the sender sometimes.

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.

Example API: pcapdotnet pcapdotnet.codeplex. Com – Steve-o Jul 31 '10 at 4:43.

You need to listen on a specific port. By passing in zero, you are assigned an arbitrary port, so you will receive only UDP datagrams addressed to it. In other words, you will receive nothing.

If you did receive something, the IPEndPoint would be filled in with information about the sender. The initial value could be used to constrain the sender.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions