Why is the call to the listen () function not needed when using a UDP socket?

I'm just curious to know about this question, can someone tell me?

+6
source share
3 answers

TCP is a streaming protocol between a server and clients. The protocol is reliable and requires a separate state for each server <> client thread. The connection protocol initiated with listen / accept sets this connection status to server <>. UDP is a connectionless protocol, an unreliable datagram (message), so there is no need to listen to new connections - datagrams can be entered in any order from any source.

+8
source

This is because UDP is not connection oriented like TCP, so there is no point in listening / receiving, for example, for SOCK_STREAM. Try reading the paragraph “2.1. Two types of Internet sockets” in the Beej Network Programming Guide and the entire manual as a whole is interesting.

+3
source

If I remember it correctly, there is no Listen () method associated with Udp, instead you call the receive () method, which is the same as Listen () when using TCP, both will block the process until packets are received. Hope this answers your question.

+1
source

Source: https://habr.com/ru/post/901888/


All Articles