tags:

views:

1412

answers:

4

In order to implement a network application that uses multicasts to send small periodic messages to other processes in the network, what choices do I have with regard to using APIs in the .Net framework? Apart from my obvious current choice, the System.net.sockets API, does WCF provide a simpler approach? Or is WCF purely a point-to-point SOA-based IPC mechanism?

Note: I'm quite conversant with the implementation details of multicast programming. What I am interested in hearing is what other choices the .Net framework offers.

+1  A: 

You just create a UDPClient and send data to a multicast address (224/4, that is any address from 224.0.0.0 to 239.255.255.255).

Your clients just listen on this address as usual.

See my answer here for more details.

P.S. Though WCF is quite an overkill for such a simple task, it's perfectly possible with WCF. There are different Message Exchange Patterns there, i. e. the ways the communication flows.

What you need is IOutputChannel for the sender and IInputChannel for the listeners, these are datagram oriented patterns.

Quassnoi
A: 

WCF is REALLY heavy for what you want to do.

Your best bet really is using the datagram's in the sockets api. They aren't too scary once you get your head around the API, but it certainly isn't the friendliest one available.

Multicasting is achieved via the address that is being sent to provided that your ISP / Network admin allows multicast data. WCF inherently doesn't allow multiple targets AFAIK, when you create a proxy, you must point it at an IP (which could be a multicast address)

Spence
Does WCF explicitly support multicast type communication? Is there some documentation on this that I can look at?
Mystic
As I said, multicast is a property of Internet Protocol, not of WCF or any other library. It is up the ISP/network admin to determine whether or not multicasting is supported.I don't believe that you can write to multicast addresses using TCP, so WCF won't be possible :(.
Spence
+2  A: 

I was going to suggest that use callback channels (i.e. a pub/sub type system) implemented in WCF, but that would require your clients to register with the 'server'.

I was then going to mention enterprise class messaging solutions like Tibco EMS (a JMS implementation).

Then I hit google and found this link: WCF Multicasting. There are lots of ideas on there which I've not yet come across in my own inital look at WCF.

ng5000
I had a look at the last link earlier, and particularly read about PeerChannels, but then decided that it was all a little too much for something simple that I was trying to accomplish. PeerChannels seem ideal for implementing P2P networks.
Mystic
A: 

FWIW, your initial question asked specifically whether WCF could achieve your goals. As Quassnoi indicated earlier you can certainly do this using WCF. While most of the literature about WCF is focused around how you use it's contract model, its possible and plausible to just use the channel model and binding structure.

If you implement the IOutputChannel and IInputChannel you can create your own datagram based channel. Is this provided as part of the framework no (and I think this is also core to your question). However, Microsoft did provide a sample of a UDP transport (which they claim supports multicast). You can find their sample at the following URL:

http://msdn.microsoft.com/en-us/library/ms751494.aspx

Ajaxx