I am trying to broadcast messages over registered multiple client over UDP protocol.
I believe we need below two commands for sending and receiving over sockets :
sendto(sock,buffer,
strlen(buffer),0,(const struct sockaddr *)&server,length);
recvfrom(sock,buffer,256,0,(struct sockaddr *)&from, &length);
As we can see , we need 6 argument for same, second last being the the address of recipient. In case of client to server , we have address. But from server to client we only have address of last client from which message have received.
I had also tried storing the addresses of all sockets who connect to server atleast once , so that we can use sendto(), But as all client are running on same machine, That &from
seems to be same.
What are alternatives available ? Where am I going wrong ? I simply want to broadcast a message to all client running on local machine. ?