Can you send a file larger that the SendBufferSize throuh a TcpClient?

半城伤御伤魂 提交于 2019-12-06 06:54:21

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/3097695/can-you-send-a-file-larger-that-the-sendbuffersize-throuh-a-tcpclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!