Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why there is no "accept()" for UDP? [closed]

Tags:

tcp

udp

I am asking it from a practical sense. In TCP, accept() will give us new socket for every connect(). It allows multiple concurrent communications with only one server port.

The questions is why we do not have such convenience in UDP? Don't tell me UDP is connectionless, hence... Logically, accept() has nothing to do with that (the underlying IP is connectionless anyway).

One consequence is that you have to apply lots of UDP ports, which may complicate firewall settings. So my next question, What is the solution for multi-client UDP application regarding port and multiplexing? In some case, I am thinking to embed client information in UDP packet and let the server differentiate. But inherently without accept(), certain to-do is hard (e.g., UDP with OpenSSL).

Thank you for the insight.

like image 986
user180574 Avatar asked Oct 05 '22 00:10

user180574


1 Answers

Because UDP is a connectionless protocol, you don't need it. You get remote address information with every incoming UDP datagram, so you know who it's from, so you don't need a per-connection socket to tell you. You don't 'have to apply lots of UDP ports' at all. You only need one.

like image 187
user207421 Avatar answered Oct 10 '22 04:10

user207421