Bas
Bas

Reputation: 477

Is there a limit to the number of UDP sockets, that can be used at a time?

I need to use a lot of UDP Sockets pointing to different UDP ports for Receive function. Hence I have opened a lot of sockets and have used BeginReceive() to call the respective callback function when a frame arrives in the particular ports.

Is there a limit to the number of sockets that I can keep open, at a time?

Thank You

Upvotes: 1

Views: 2727

Answers (1)

Luaan
Luaan

Reputation: 63772

Sure, there's always limits:

  • Amount of available ports. The absolute maximum would be 65535, but the true maximum is much more limited.
  • Amount of available memory to handle the state for each of the sockets.
  • Amount of memory for the receive buffers.

You'll find more examples, of course. But the port number limit is an absolute hard limit. Well, as long as you only have one IP address, of course. Nothing prevents you from having a few different network cards in your computer, or VPNs for example...

The more important question is "why?". UDP is message-based - it's actually quite easy to handle messages from thousands (and more) clients with just a single socket. Unlike TCP, UDP doesn't have any exclusive connections.

Upvotes: 4

Related Questions