Multicast support in .Net

北城余情 提交于 2019-12-05 05:51:55

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.

Quassnoi

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.

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)

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!