开发者

Does a new socket open for every UDP connection?

开发者 https://www.devze.com 2023-01-23 16:16 出处:网络
I know that with TCP each con开发者_StackOverflow中文版nection creates a new socket.Does UDP also create a new socket for each connection?No.

I know that with TCP each con开发者_StackOverflow中文版nection creates a new socket. Does UDP also create a new socket for each connection?


No.

When you receive a message (recvmsg()), you are told the IP address of the peer that sent the message; when you respond (sendmsg()), you specify the IP address to which the message goes. This is done over a single socket. See also <sys/socket.h>.


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

You have that back to front. Each new socket represents a new connection.

Does UDP also create a new socket for each connection?

That doesn't make sense either. First there are no real connections in UDP. Second, it is you who creates the sockets, or your application. Not UDP. Or TCP.

0

精彩评论

暂无评论...
验证码 换一张
取 消