user1907813
user1907813

Reputation: 1

Broadcast data from .NET application to another

I have two applications on a local network A and B, The application A should be the server and broadcast an array of data to all instances of application B, if the any instance of application B received an item of this array another B instances will not receive this item, also any instance if application B is able to start before or after application A starting (communication between two applications will not effect). What is the best technology or method in .NET to apply this scenario?.

Upvotes: 1

Views: 53

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062745

The single-delivery means this isn't really a broadcast: you can't "broadcast" and limit it to one receiver. The need to work an A means that it can't be TCP sockets.

It sounds like you want a middleware box in the middle as a work queue. A can add items to the queue, and instances of B can dequeue items. I would use something like redis, because it is trivial to setup, free, and very efficient. In the context of redis, A would call RPUSH (to put new items at the end), and each B would call LPOP (to remove items from the start). Each B could simply poll periodically when there isn't data; when it has removed data it can just LPOP in a loop until the data runs out, then poll periodically instead. There is also a blocking pop (BLPOP) if you don't want to loop tightly, but I'm not a fan of that personally; if I need to know immediately of new data, I'd rather use the inbuilt pub/sub (PUBLISH / SUBSCRIBE) to send a "there's new data" message that just makes the clients look with LPOP.

There are various redis clients avaiable to .NET.

Other than the individual commands mentioned, most of the above would translate to any form of message bus; MSMQ, etc.

Upvotes: 1

Related Questions