C 语言里不支持的 TCP 窗口大小调整吗

holinhot:gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)编译的时候报错误。

*server2.c: In function ‘create_server_fd’:
server2.c:81:42: error: ‘TCP_WINDOW_CLAMP’ undeclared (first use in this function)
if (setsockopt(serverfd, SOL_SOCKET, TCP_WINDOW_CLAMP, (char )& WINDOW_CLAMP, sizeof(WINDOW_CLAMP)) < 0)
^
server2.c:81:42: note: each undeclared identifier is reported only once for each function it appears in

int serverfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
    int REUSEADDR = 1;
    int REUSEPORT = 1;
    int WINDOW_CLAMP = 1;
    if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&REUSEADDR, sizeof(REUSEADDR)) < 0)
        perror("setsockopt(SO_REUSEADDR) failed");
    if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEPORT, (const char*)&REUSEPORT, sizeof(REUSEPORT)) < 0)
        perror("setsockopt(SO_REUSEPORT) failed");
    if (setsockopt(serverfd, SOL_SOCKET, TCP_WINDOW_CLAMP, (char *)& WINDOW_CLAMP, sizeof(WINDOW_CLAMP)) < 0)
        perror("setsockopt(TCP_WINDOW_CLAMP) failed");


    if (serverfd == -1)
        EXIT("create socket fail");

jjshare:头文件没引?

holinhot:@jjshare 有引入,前面加的两个 SO_REUSEPORT 和 SO_REUSEADDR 没问题

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <ctype.h>

jedihy:#include <netinet/tcp.h>

holinhot:@jedihy 引入 include <netinet/tcp.h>是不报错误了,不过 TCP_WINDOW_CLAMP 参数不生效。用 python 测试 TCP_WINDOW_CLAMP 是可以生效的。

holinhot:@jedihy 可以了 TCP_WINDOW_CLAMP 是 IPPROTO_TCP 下的参数。c 新手

在网络环境比较差的情况下,应该开单 TCP 链接还是多个 TCP 链接?

Pino44:假设网络环境比较差,速率较慢,现在需要下载一个大文件,假设服务器支持分段的传输,是建立单个 TCP 连接还是多个 TCP 连接更好?Osk:反正我下 vps 上的文件都是暴力线程,16 起步 128 封顶。单线程几十 k,多线程上 MB,用脚投票都用多个连接呀。下载中断就续传,下完了双方校验 sha 完事 lambdaq:网络差也分好几种。丢包…

分享一个不到 200 行代码的 TCP 内网穿透程序。

FreeEx:使用场景 1:内网穿透 使用场景 2:转发报文 项目地址: https://github.com/dushixiang/4dnatest:一行 socat 也可以(滑稽。。

联通家宽 IPv6 无法接受入站 TCP 请求?

de1ta:环境: 联通家宽 200M 光猫 HG2201U 1.0:防火墙等级低(无法关闭)、攻击保护关、QOS 关、光猫拨号(路由拨号存在降速、丢包、断连的问题) 内网 IPv4 、公网 ipv6 、test-ipv6 10 分 路由 AC86U 、IPv6 passthrough 需求:使用 ddns 动态解析 v6 地址,从境内公网直连家庭 NAS,…

将谓词<T>转换为Func <T,bool> - c#

我有一个包含成员Predicate的类,希望在Linq表达式中使用该类:using System.Linq; class MyClass { public bool DoAllHaveSomeProperty() { return m_instrumentList.All(m_filterExpression); } private IEnumerable&…

Junit4和TestNG与Maven在一个项目中 - java

要一起运行它们,几乎没有可用的选项,但是我选择为Junit和TestNG使用不同的配置文件。但是现在的问题是排除和包含测试用例。由于如果我们在Maven的主项目中添加testNG依赖项,它将跳过所有Junit,因此我决定将其放在单独的配置文件中。所以我使用pom.xml中的以下条目从默认(主要)配置文件中排除了TestNG测试:<plugin> …