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");
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.