https://stackoverflow.com/questions/4883689/send-same-packets-to-multiple-clients
question:
I have to develop a software to send same packets to multiple destination. But i must not use multicast scheme.!!!! ( because my boss is a stupid man ) so, any way, the problem is that: i have same packets and multiple IP address ( clients) and i can not use multicast how can i do that in the best way? i must use c++ as a language and Linux as a platform. so please help me
answer:
This could be done with either TCP or UDP depending on your reliability requirements. Can you tolerate lost or reordered packets? Are you prepared to handle timeouts and retransmission? If both answers are "yes", pick UDP. Otherwise stay with TCP. Then:
sendto(2)
on the same data for each address/port. The clients would have to be recv(2)
-ing at that time. If you don't know your clients upfront you'd need to devise a scheme for clients to request the data, or just register with the server. That's where recvfrom(2)
is usefull - it gives you the address of the client.