when is the push flag set in tcp segment

纵饮孤独 提交于 2019-12-03 14:26:35

The PUSH flag is used by the tcp stack to basically say "i'm done for now". It's just indicating the data segment is fully transmitted by the source.

There is no way to indicate or control it in userland (your socket api), as this is just the tcp stack/implementation to do it. As the URGENT flag.

(Source: Richard Stevens - Tcp/ip illustrated vol 1, chapter 20)

You can set the URGENT flag using send() with the MSG_OOB flag set. As this implies, the data sent will be Out-Of-Band, meaning it will not normally be received by the calling side simply calling read(). The receiving side will get some indication of OOB data like the signal SIGURG, or the socket will become exceptional and can be checked as such using select().

Most of the time you don't want to set the URGENT flag.

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