Reputation: 4976
I know that with TCP each connection creates a new socket. Does UDP also create a new socket for each connection?
Upvotes: 3
Views: 1789
Reputation: 311039
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.
Upvotes: 2
Reputation: 754940
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>
.
Upvotes: 7