Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SO_NOSIGPIPE was not declared

Tags:

c

tcp

sockets

I am trying to use SO_NOSIGPIPE in a tcp socket.

  int set = 1;
  setsockopt(sockDesc, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int);

but an error is coming:

   error: SO_NOSIGPIPE was not declared in this scope

Is there any header files required, to use that. I have searched over the Internet but didn't get any useful solution.

like image 912
Ankur Avatar asked Nov 05 '14 08:11

Ankur


1 Answers

There is no SO_NOSIGPIPE in Linux (nor some other systems). You can instead use the MSG_NOSIGNAL flag when calling send(), or use signal(SIGPIPE, SIG_IGN) to make your entire application ignore SIGPIPE.

like image 151
John Zwinck Avatar answered Sep 29 '22 17:09

John Zwinck