简体   繁体   English

在WCF中,何时应该使用TCP绑定?

[英]In WCF , when should a TCP binding be used?

In WCF , when should a TCP binding be used? 在WCF中,何时应该使用TCP绑定? I know the scenario when web browser is the WCF client. 我知道Web浏览器是WCF客户端时的情况。 In that case HTTP is used. 在那种情况下使用HTTP。 But what are the scenarios for TCP ? 但是TCP的场景是什么?

Thanks for ur replies. 谢谢你的回复。

Basically, whenever you can! 基本上,只要你可以! NetTcp is much more efficient than http - it's encoding binary which saves a lot of bandwidth, and it has other properties which make it really really fast. NetTcp比http更高效 - 它的编码二进制文件可以节省大量带宽,并且它具有其他特性,使其真正非常快。

Trouble is: the other end of the communication (you always have a server and a client) also must understand this protocol. 麻烦的是:通信的另一端(你总是有服务器和客户端)也必须理解这个协议。 It's .NET specific, so any non-.NET client will not able to use it. 它是特定于.NET的,因此任何非.NET客户端都无法使用它。

Also, NetTcp doesn't typically use port 80, so if you want to use it over the internet, you'll have to open up ports on firewalls to let the traffic go through - not always easy and possible. 此外,NetTcp通常不使用端口80,因此如果您想通过互联网使用它,您将不得不在防火墙上打开端口以让流量通过 - 并非总是容易和可能。

But if you have an intranet scenario - eg your company's LAN environment - and you have .NET clients calling your WCF service, there's no reason at all not to use NetTcp ! 但是,如果您有一个Intranet场景 - 例如您公司的LAN环境 - 并且您有.NET客户端调用您的WCF服务,那么根本没有理由使用NetTcp!

The NetTcpBinding is the most efficient in terms of overhead and bandwidth utilization. NetTcpBinding在开销和带宽利用率方面是最有效的。 As soon as you have a native .NET client you should use it. 只要您拥有本机.NET客户端,就应该使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM