Can you send a file larger that the SendBufferSize

2019-04-12 11:51发布

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?

2条回答
成全新的幸福
2楼-- · 2019-04-12 12:33

From MSDN:

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.

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

查看更多
不美不萌又怎样
3楼-- · 2019-04-12 12:51

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. You can achieve greater data throughput by ensuring that your network buffer is at least as large as your application buffer.

from .NET Framework Class Library - TcpClient.SendBufferSize Property

查看更多
登录 后发表回答