问题描述
为了实现使用多播发送小周期的消息到网络中其他进程的网络应用程序,我有关于使用API在.NET Framework有什么选择?除了我明显的电流选择,的System.Net.Sockets API,并WCF提供了一个更简单的方法?或者是WCF纯属点至点基于SOA的IPC机制?
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?
注意:我很熟悉的多播节目的实施细节。我所感兴趣的听证会还有什么其他的选择.net框架的优惠。
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.
推荐答案
您只需要创建一个 UDPClient
和发送数据到多播地址( 224 / 4
,也就是从 224.0.0.0
到 239.255.255.255
)的地址。
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.
请参阅我的回答here了解更多详情。
See my answer here for more details.
P.S。虽然 WCF
是一个相当矫枉过正这样一个简单的任务,这是完全可能的 WCF
。有不同的消息交换模式
在那里,我。即该方式的通信流。
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.
您需要的是 IOutputChannel
发件人和 IInputChannel
的监听器,这些都是数据报导向花纹。
What you need is IOutputChannel
for the sender and IInputChannel
for the listeners, these are datagram oriented patterns.
这篇关于在净多播支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!