简体   繁体   中英

Is Socket.Send buffer size limited?

发送缓冲区大小是否有任何限制,我可以发送小包-ie:1000字节 - 但是当我尝试发送大约20K没有任何反应时,远程将不会收到数据包加上远程将不再接收任何数据。

System.Net.Sockets.Socket.Send((byte)buffer);

Send() returns an Int32 indicating how many bytes were sent.. so one can infer that the upper limit on your buffer size is Int32.MaxValue.

As far as why you are having trouble with a 20k byte buffer - you have not provided enough information to make a guess.

As the docs state, this method returns the number of bytes sent. It is your responsibility to then send the leftover bytes.

The Socket.SendBuffer default buffer size is 8192 according to MSDN. You can increase this if needed.

tcpSocket.SendBufferSize = 8192;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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