Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 所以_NOSIGPIPE没有申报_C_Sockets_Tcp - Fatal编程技术网

C 所以_NOSIGPIPE没有申报

C 所以_NOSIGPIPE没有申报,c,sockets,tcp,C,Sockets,Tcp,我正在尝试在tcp套接字中使用SO_NOSIGPIPE int set = 1; setsockopt(sockDesc, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int); 但一个错误正在到来: error: SO_NOSIGPIPE was not declared in this scope 要使用它,是否需要任何头文件。我在互联网上搜索过,但没有找到任何有用的解决方案。Linux(或其他一些系统)中没有所以_

我正在尝试在tcp套接字中使用SO_NOSIGPIPE

  int set = 1;
  setsockopt(sockDesc, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int);
但一个错误正在到来:

   error: SO_NOSIGPIPE was not declared in this scope

要使用它,是否需要任何头文件。我在互联网上搜索过,但没有找到任何有用的解决方案。

Linux(或其他一些系统)中没有
所以_NOSIGPIPE
。您可以在调用
send()
时使用
MSG\u NOSIGNAL
标志,或者使用
signal(SIGPIPE,SIG\u IGN)
使整个应用程序忽略
SIGPIPE

它的可能重复项不是标准选项,您需要找到另一种处理(或忽略)信号的方法。有关所有标准选项的列表,请参见,例如……也许这对您有所帮助?我包括并使用了信号(信号管、信号灯),它对我很有用。非常感谢。