TCP options: Intro

According to RedHat accessories

TCP_NODELAY: each call to write(fd, buf...) will be sent out as packet. This leads to poor overall performance when most of the writes are small. However, use writev(fd, iov...) with this option to build packet may lead to better latency.

TCP_CORK: Very impressive to describe this option as to add a cork to nic when enabled. After disabling this option, the accumulated packets are sent out immediately(the logical packets are coalesced).

Enable and disable sockopt:

// Enable
int one = 1;
setsockopt(descriptor, SOL_TCP, TCP_CORK, &one, sizeof(one));

// Disable
int zero = 0;
setsockopt(descriptor, SOL_TCP, TCP_CORK, &zero, sizeof(zero));

And no sockopts are set in default case.

 

posted on 2018-08-30 20:58  三叁  阅读(118)  评论(0编辑  收藏  举报

导航