0
votes

(I'm new to network programming, and I am working on C in Linux) I followed Beej's guide for a simple UDP listener-talker and I know how to create a socket and send that to a destination (with calls to getaddrinfo() and socket() using SOCK_DGRAM) See http://beej.us/guide/bgnet/output/html/multipage/clientserver.html#datagram.

In my distributed app, I will need to send a message to multiple peers (reliable multicast). My question is: do I need to create a socket for each of the peers? I'm worried about scalability. Or should I create the socket, use it and destroy it (close it) after each message?

In summary, is there a good way to send a UDP packet to multiple destinations, periodically? Thanks for the help!

1
I'm concerned by your use of UDP and reliable in the same message :) UDP is not reliable - any part of the communication chain is allowed to drop the packet.DrC

1 Answers

1
votes

For UDP, you need but one local socket. You can send a packet to any destination you like from that one, single socket.

Also, you don't need to destroy and recreate the socket after each message. Just keep the socket open, and keep sending messages.