开发者

TCP_NODELAY not found on Ubuntu

开发者 https://www.devze.com 2023-02-25 16:37 出处:网络
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 &l

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 an开发者_如何学Pythond 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;
}


Did you #include <netinet/tcp.h>?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号