C++ 在 Windows 上禁用延迟确认
我正在尝试在 Windows 计算机上复制实时应用程序,以便能够更轻松地进行调试和更改,但我遇到了延迟确认问题.我已经禁用了 nagle 并确认它稍微提高了速度.当发送大量小数据包时,window 不会立即确认并延迟 200 毫秒.对此进行了更多研究,我遇到了 这个.更改注册表值的问题在于,它会影响整个系统,而不仅仅是我正在使用的应用程序.无论如何,是否可以使用 setsockopt
从 linux 禁用像 TCP_QUICKACK
这样的窗口系统上的延迟 ACK?我尝试硬编码 12,但从 WSAGetLastError 得到 WSAEINVAL.
I am trying to replicate a real time application on a windows computer to be able to debug and make changes easier, but I ran into issue with Delayed Ack. I have already disabled nagle and confirmed that it improve the speed a bit. When sending a lots of small packets, window doesn't ACK right away and delay it by 200 ms. Doing more research about it, I came across this. Problem with changing the registry value is that, it will affect the whole system rather than just the application that I am working with. Is there anyway to disable delayed ACK on window system like TCP_QUICKACK
from linux using setsockopt
? I tried hard coding 12, but got WSAEINVAL from WSAGetLastError.
我在 github 上看到一些开发人员提到使用 SIO_TCP_SET_ACK_FREQUENCY
但我没有看到任何关于如何实际使用它的示例.
I saw some dev on github that mentioned to use SIO_TCP_SET_ACK_FREQUENCY
but I didn't see any example on how to actually use it.
所以我尝试在下面做
#define SIO_TCP_SET_ACK_FREQUENCY _WSAIOW(IOC_VENDOR,23)
result = WSAIoctl(sock, SIO_TCP_SET_ACK_FREQUENCY, 0, 0, info, sizeof(info), &bytes, 0, 0);
我得到了 WSAEFAULT 作为错误代码.请帮忙!
and I got WSAEFAULT as an error code. Please help!
我在网上看到几个参考资料说 TCP_QUICKACK
可能实际上是由 Winsock 通过 支持的setsockopt()
(选项 12),即使它没有记录在案,也没有在任何地方得到官方确认.
I've seen several references online that TCP_QUICKACK
may actually be supported by Winsock via setsockopt()
(opt 12), even though it is NOT documented, or officially confirmed anywhere.
但是,关于您的实际问题,您对 SIO_TCP_SET_ACK_FREQUENCY
的使用失败了,因为您没有向 WSAIoctl()
提供任何输入缓冲区来设置实际频率值.尝试这样的事情:
But, regarding your actual question, your use of SIO_TCP_SET_ACK_FREQUENCY
is failing because you are not providing any input buffer to WSAIoctl()
to set the actual frequency value. Try something like this:
int freq = 1; // can be 1..255, default is 2
result = WSAIoctl(sock, SIO_TCP_SET_ACK_FREQUENCY, &freq, sizeof(freq), NULL, 0, &bytes, NULL, NULL);
请注意,SIO_TCP_SET_ACK_FREQUENCY
在 Windows 7/Server 2008 R2 及更高版本中可用.
Note that SIO_TCP_SET_ACK_FREQUENCY
is available in Windows 7 / Server 2008 R2 and later.