when is the push flag set in tcp segment

Rohit Banga picture Rohit Banga · Feb 15, 2010 · Viewed 10.5k times · Source

i asked this previous question here:

tcp two sides trying to connect simultaneously

i tried the method given in the solution and while sending while using netcat and sniffing packets with ethereal i observed that when i sent a "hello" string from one side to the other it was sent in a segment with the push flag set.

who decides to set the push flag? what are the rules for setting the push or urgent flag in a tcp segment? is it possible to do it using the sockets api?

Answer

Patrick picture Patrick · Feb 15, 2010

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)