0

If I am not reading data from socket fast enough, the TCP protocol will decrease sliding windows size and sender might get blocked during sending (as discussed here what happens when I don't manage to call `recv` fast enough?).

How do I detect this situation on receiver side on Windows - preferably directly in C# code and without impacting the performance of reading from socket? Other monitoring solution (perfmon, wireshark) is also acceptable but far less optimal for my scenario.

What is the exact scenario? Let's say the server app can transmit data with speed up to 1Mbps, however my client app is able to receive the data only with the speed of 0.5Mbps. How do I find out in the client application that TCP flow control is kicking in and decreasing the transmit speed?

I came over Socket.Available property http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.available.aspx and was wondering if that might be recomendable way of querying this information?

4

2 回答 2

1

您最好尽可能快地阅读,而不是浪费时间试图让系统告诉您您阅读速度不够快,这只会进一步减慢您的阅读速度。如果您正在以最大速度阅读并且发件人仍然被阻止,则 TCP 工作正常,您无能为力,除非查看更快的机器。

于 2013-06-05T23:37:21.997 回答
0

TCP 窗口由内核处理,您无法使用。我想您可能会将 ReceiveBufferSize 与接收的字节数进行比较。如果此缓冲区未满,则您正在等待。

于 2013-06-05T17:00:52.883 回答