简体   繁体   中英

TCP_NODELAY not found on Ubuntu

I am trying to disable the Nagle's Algorithm with my TCP sockets on an Ubuntu Linux box by setting the TCP_NODELAY parameter. For some reason, this constant is not defined in <sys/types.h> or <sys/socket.h> . Has this constant been deprecated and then removed from Linux or am I just missing something?

bool Socket::setTCPNoDelay(bool enabled)
{

    int flag = (enabled ? 1 : 0);

    if(setsockopt(m_sock,IPPROTO_TCP,TCP_NODELAY,(char *)&flag,sizeof(flag)) == -1)
    {
         return false;
    }

    return true;
}

#include <netinet/tcp.h>了吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM