Does a new socket open for every UDP connection?

I know that with TCP every connection creates a new socket. Does UDP also create a new socket for each connection?

+3
source share
2 answers

No.

When you receive a message ( recvmsg()), you are informed of the IP address of the partner who sent the message; when you reply ( sendmsg()), you indicate the IP address the message goes to. This is done through one socket. See also <sys/socket.h>.

+7
source

I know that with TCP every connection creates a new socket.

You have it back. Each new socket represents a new connection.

Does UDP create a new socket for each connection?

. -, UDP . -, . UDP. TCP.

+2

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


All Articles