错误:“TCP_NODELAY”未在此范围内声明

错误:“TCP_NODELAY”未在此范围内声明

我正在尝试在 Ubuntu 16.04 中编译 ChatScipt v7.55。但是当我使用make server命令时,我收到此错误:

evserver.cpp: In function ‘int settcpnodelay(int)’:
evserver.cpp:263:40: error: ‘TCP_NODELAY’ was not declared in this scope
     return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*) &on, sizeof(on));
                                        ^
Makefile:110: recipe for target 'evserver.o' failed
make: *** [evserver.o] Error 1

这是该命令的完整结果:

************ LINUX VERSION ************
g++ -c  -std=c++11 -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing  -DLOCKUSERFILE=1  -DEVSERVER=1 -DEVSERVER_FORK=1  -DDISCARDPOSTGRES=1 -DDISCARDMONGO=1 -DDISCARDMYSQL=1  -Ievserver evserver.cpp -o evserver.o
evserver.cpp: In function ‘int settcpnodelay(int)’:
evserver.cpp:263:40: error: ‘TCP_NODELAY’ was not declared in this scope
     return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*) &on, sizeof(on));
                                        ^
Makefile:110: recipe for target 'evserver.o' failed
make: *** [evserver.o] Error 1

有什么问题以及如何解决它?

答案1

我通过添加 #include <netinet/tcp.h> 上面的“evserver.cpp”文件解决了这个问题

相关内容