I am trying to change the delayed_ack value to 0 from 3(default) in OS X. I can change the send space programmatically, but not the delayed_ack. Thoughts ? thanks.
int sendspace,retval,new_sendspace,len;
len = sizeof(sendspace);
new_sendspace = 131072;
retval = sysctlbyname("net.inet.tcp.sendspace", &sendspace, &len,&new_sendspace, &len);
The above works.
// Turn off delayed Ack
int delayed_ack = 0;
len = sizeof(delayed_ack);
retval = sysctlbyname("net.inet.tcp.delayed_ack", &delayed_ack, &len, &delayed_ack,
&len);
printf("retval for delayed ack is %d\n",retval);
The delayed_ack never gets set to 0.
Found my answer. This is how you do it.
setsockopt(sockfd,IPPROTO_TCP, TCP_NODELAY,(char *) &flag, sizeof(int));