问题描述:

Disclaimer: I know that UPD is a connectionless protocol. That's why I put connection into quotation marks.

I want to communicate to different remote machines using UDP (no, I don't want to use TCP). What is the best way to achieve this with .NET sockets?

Two possibilities came to my mind:

  • I could use many sockets (one per remote machine) and use Connect() to connect to each of them to different remote ports
  • I could create one socket which calls BeginReceiveFrom without Connecting and thus gathers data from all remote hosts.

Which solution is better and why? Which has better scalability (i.e., is able to support more remote hosts efficiently)?

相关阅读:
Top