的TcpClient VS套接字在C# [英] TCPClient vs Socket in C#
问题描述
我看不出太大的用处的TcpClient
的,但是有很多插槽
的?什么是它们之间的主要区别,当你会使用的呢?
I don't see much use of TCPClient
, yet there is a lot of Socket
? What is the major difference between them and when would you use each?
据我所知,.NET 插槽
写Winsock的顶部,而的TcpClient
是一个包装过插槽
类。因此,的TcpClient
是一路链,并可能效率低下。纠正我,如果我错了。
I understand that .NET Socket
is written on top of WINSOCK, and TCPClient
is a wrapper over Socket
class. Thus TCPClient
is way up the chain, and possibly inefficient. Correct me if I am wrong.
感谢
推荐答案
使用的TcpClient和的TcpListener只是意味着code少一些行。正如你所说的,它只是一个包装过的Socket类,所以它们之间性能差异是纯粹一种风格的选择。
The use of TcpClient and TcpListener just means a few less lines of code. As you say it's just a wrapper over the Socket class so there is no performance difference between them it's purely a style choice.
这篇关于的TcpClient VS套接字在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!