34

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;
}
Dada
  • 6,313
  • 7
  • 24
  • 43
rplankenhorn
  • 2,075
  • 2
  • 22
  • 32

1 Answers1

71

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

dgnorton
  • 2,237
  • 16
  • 12