c - Different ways/approaches to how to send notification to every suscriber in a server/client tcp implementation -


so not make question way vague, want show i've thought far, , right have client (subscriber) connect , sends messages server (intermediary between subscribers , editors).

i have list store every topic subscriber can subscribe to, , list of subscribers each node of list.

as of right subscribers can register or drop out topic. issue notify every subscriber of topic when editor generate event.

to thought of, well, go through list of topic of event, , send message each subscriber of said topic, subscriber gets it, he's been notified.

but way can think of right have code:

int sock_tcp;  struct sockaddr_in  dir_tcp_srv;   sock_tcp=socket(af_inet,sock_stream,0); if(sock_tcp<0) {   fprintf(stdout,"error\n");   exit(1); }  bzero((char*)&dir_tcp_srv,sizeof(struct sockaddr_in));  dir_tcp_srv.sin_family=af_inet; dir_tcp_srv.sin_addr.s_addr=inet_addr(address_previously_stored); dir_tcp_srv.sin_port=htons(port_previously_stored); if(connect(sock_tcp,                      (struct sockaddr*)&dir_tcp_srv,      sizeof(struct sockaddr_in))<0) {    perror("connect error");   close(sock_tcp); exit(1); } 

where put on function example (this code use connect subscribers intermediary process), , give 2 paramters address , port, , go through list, calling code each time different parameters.

this seems bit dumb me , i'm missing kind of point or concept, in sense i'm using same code of time , seems bit of waste. believe different implementation kind of broadcast , subscriber info it's "push" subscriber-editor mode believe idea 1 fits concept (instead of doing pull subscriber whenever wants info , on).

thanks in advance.

tcp peer peer protocol has 2 ends , connection oriented. if stick tcp communication mechanism this, have iterate though subscribers setup connection, send , close because tcp not multicast.

if use udp broadcast confined in boundaries of subnet.


Popular posts from this blog