Linux c socket TCP_NODELAY fast send

来源:互联网 发布:caffe 训练自己的数据 编辑:程序博客网 时间:2024/05/22 02:06
If you want send packet immediately. Try this

         int flag = 1;
int result = setsockopt(sock, /* socket affected */
IPPROTO_TCP, /* set option at TCP level */
TCP_NODELAY, /* name of option */
(char *) &flag, /* the cast is historical
cruft */
sizeof(int)); /* length of option value */
if (result < 0)
... handle the error ...


leo friendly note: TCP_NODELAY is in <netinet/tcp.h>
 
原创粉丝点击