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

后端 未结 3 1784
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 03:32

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         


        
3条回答
  •  有刺的猬
    2021-01-14 04:01

    RECEIVE on 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!)

    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

提交回复
热议问题