以编程方式使用sysctl设置tcp延迟ack

时间:2013-02-28 01:36:20

标签: macos tcp sysctl

我试图在OS X中将delayed_ack值从3(默认)更改为0.我可以通过编程方式更改发送空间,但不能更改delayed_ack。想法?感谢。

int sendspace,retval,new_sendspace,len;
len = sizeof(sendspace);
new_sendspace = 131072;
retval =    sysctlbyname("net.inet.tcp.sendspace", &sendspace, &len,&new_sendspace, &len);

以上作品。

// 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);    

delayed_ack永远不会设置为0。

1 个答案:

答案 0 :(得分:0)

找到我的答案。这就是你如何做到的。

setsockopt(sockfd,IPPROTO_TCP, TCP_NODELAY,(char *) &flag, sizeof(int));