简体   繁体   English

.NET远程处理-HttpChannel与TcpChannel

[英].NET Remoting - HttpChannel vs TcpChannel

I'm new to .NET Remoting and not very familiar with the different communication channels which can be used. 我是.NET Remoting的新手,对可以使用的各种通信渠道不是很熟悉。 I know there is HttpChannel and TcpChannel out of the box. 我知道开箱即用的是HttpChannel和TcpChannel。 I understand that one is Http while the other is Tcp, but I don't understand why Tcp is faster. 我知道一个是Http,另一个是Tcp,但是我不明白为什么Tcp更快。

The HTTP channel has to create a huge (relatively speaking) header and parse complex responses. HTTP通道必须创建一个巨大的(相对而言)标头并解析复杂的响应。 The TCP channel on the uses an efficient binary protocol with much less overhead per request. 上的TCP通道使用高效的二进制协议,每个请求的开销要少得多。

TCP is slightly faster than HTTP; TCP比HTTP快一点; HTTP defaults to using the slower Soap formatter and TCP defaults to using the faster Binary formatter; HTTP默认使用较慢的Soap格式化程序,TCP默认使用较快的二进制格式化程序。 HTTP supports the faster Binary formatter - you just need to select it HTTP支持更快的二进制格式化程序-您只需要选择它

Source: Factoids about HTTP and TCP remoting channels 来源: 有关HTTP和TCP远程通道的事实

The reason Tcp is faster, is that it uses binary as a means of data transmission across the wire, with TcpChannel, you can use any port number above 1024 (the first 1024 ports are reserved). Tcp更快的原因是,它使用二进制文件作为跨线数据传输的一种方式,通过TcpChannel,您可以使用1024以上的任何端口号(保留前1024个端口)。 Whereas with HttpChannel, it is using port 80, the standard port that is shared with your web browser, the HttpChannel is used if you want to make it flexible with other services. HttpChannel使用的是端口80(与您的Web浏览器共享的标准端口),而HttpChannel是您想使其灵活用于其他服务的端口。 Furthermore, data passed through the HttpChannel are encoded in text, which makes it slower, for an example, if you were to retrieve an image, that image would have to be encoded first into Base64 data format and transferred across. 此外,通过HttpChannel传递的数据是用文本编码的,这使其速度变慢,例如,如果要检索图像,则必须首先将该图像编码为Base64数据格式并进行传输。

Generally, if you want speed, go for TcpChannel, if you want flexibility, go for HttpChannel. 通常,如果要提高速度,请选择TcpChannel,如果需要灵活性,请选择HttpChannel。

Hope this helps, Best regards, Tom. 希望这对您有所帮助,汤姆,谢谢。

Tcp is faster because it is a faster protocol. Tcp更快,因为它是一个更快的协议。

Tcp is a lower level protocol that can establish a secure reliable connection. Tcp是可以建立安全可靠连接的较低级别协议。 Http is easier to use as you can send it to a web server from your browser. Http易于使用,因为您可以将其从浏览器发送到Web服务器。

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

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