您可以发送文件较大的SendBufferSize throuh一个TcpClient的?您可以、较大、文件、TcpClient

2023-09-03 23:05:51 作者:回忆ヽ无与伦比的伤

我尝试用TCP连接在.NET中,我想送一些数据比对的TcpClient对象的SendBufferSize proporty较大。是否有可能通过简单地写网络流或发送数据,我需要把它切PICES,并把这些和在另一端重新创建它?

I am experimenting with the Tcp connections in .NET and I would like to send some data that is larger than the SendBufferSize proporty of the TcpClient object. Is it possible to send the data by simply writing to the network stream or do I need to cut it in pices and send those and at the other end create it again?

推荐答案

从的 MSDN :

如果网络缓冲区比数据的您提供的Write方法的金额较小,一些网络发送操作将被执行的每一个打电话给你做出Write方法。

If the network buffer is smaller than the amount of data you provide the Write method, several network send operations will be performed for every call you make to the Write method.

您只需要调用一次编写,该TcpClient的将处理拆分为多个网络运营。

You only need to call Write once, the TcpClient will handle splitting it into multiple network operations.