Is there an equivalent to TCP_CORK in Winsock?

岁酱吖の 提交于 2019-11-30 23:31:51

FWIW I successfully use TCP_NODELAY to get TCP_CORK-style behavior. I do it like this:

  1. unset the TCP_NODELAY flag on the socket
  2. Call send() zero or more times to add your outgoing data into the Nagle-queue
  3. set the TCP_NODELAY flag on the socket
  4. call send() with the number-of-bytes argument set to zero, to force an immediate send of the Nagle-queued data

That works fine for me under Windows, MacOS/X, and Linux. (Note that under Linux the final zero-byte send() isn't necessary)

There is no equivalent. The best you can do is gather your data pieces into your own buffer first, and then send the completed buffer to the socket when ready, and let Nagle handle the packets normally.

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