NetTcpBinding 和 NetPeerTcpBinding 之间的区别

Differences between NetTcpBinding and NetPeerTcpBinding

WCF 中 NetTcpBinding 和 NetPeerTcpBinding 的实际区别是什么?我什么时候应该选择一个而不是另一个?

TCP 绑定

NetTcpBinding 由 NetTcpBinding class 提供,TCP 绑定使用 TCP 进行跨机通信 在内网上。它支持多种特性,包括可靠性、 事务和安全性,并针对 WCF 到 WCF 通信进行了优化。作为 结果,它要求客户端和服务都使用 WCF

对等网络绑定

NetPeerTcpBinding class 提供,它使用对等网络作为传输: 启用对等网络的客户端和服务都订阅了同一个网格,并且 向它广播消息。对等网络需要了解网格拓扑和网格计算策略。选择对等绑定的人这样做是因为他们 实际上是在隐式发现机制或发布订阅机制之后。

Peer Network binding

This binding is provided by the NetPeerTcpBinding class. It uses TCP protocol but uses peer net-working as transport. In this networking each machine (node) acts as a client and a server to the other nodes. This is used in the file sharing systems like torrent.

TCP binding

This binding is provided by the NetTcpBinding class. It uses TCP protocol for communication be-tween two machines with in intranet (means same network). It encodes the message in binary format. This is faster and more reliable binding as compared to the Http protocol bindings. It is only used when communication is WCF - to – WCF means both client and service should have WCF.

有关绑定的更多信息: Bindings

简单来说: 实际区别在于 NetTCP 有服务器端和客户端应用程序,在 peer2peer 应用程序中,客户端和服务器都为其他客户端工作。 P2P 适用于文件压缩(如 Torrent)。 NetTCP 更适合 "normal" 应用程序,其中您有连接到数据存储的服务器,以及使用服务器访问数据和服务器逻辑的客户端。