MSG_NOSIGNAL undeclared

When trying to compile this code:

I got an error message about MSG_NOSIGNAL being undeclared

g++ -c -o ServerSocket.o ServerSocket.cpp
g++ -c -o Socket.o Socket.cpp
Socket.cpp: In method bool Socket::send(basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >) const': Socket.cpp:112: MSG_NOSIGNAL’ undeclared (first use this function)
Socket.cpp:112: (Each undeclared identifier is reported only once
Socket.cpp:112: for each function it appears in.)
make: *** [Socket.o] Error 1

Is there a fix?

MSG_NOSIGNAL is a proprietary Linux manifest (i.e. it is non-posix/Xopen). Just replace it with 0 (the number 0).

The posix/xopen way of accomplishing the same result is to use sigprocmask/sigwait (see: … gwait.html) to direct all signals synchronously to a signal handling thread.

Before continuing any further, make sure you understand this issue completely, as it is a fundamental element of multi-threaded programming.

so could I use pthread_sigmask to tell that thread to ignore SIGPIPE signals and check return code and errno to detect broken pipe? What I want to do ultimately is a client-server mechanism where both ends would try to reconnect when communication is broken.

The BSD’s have been bringing this in. MSG_NOSIGNAL
will be supported in 6.4


Almost… you must block SIGPIPE at the process level, since you can’t control which thread will pick it up otherwise. You should mask all signals and dedicate a thread to processing them synchronously. Any good book on pthreads will recommend this idiom.

If you are using QNX 6.4, then you can (as Sean suggests) just recompile against io-pkt which does have this manifest. Of course, this is non-posix.

I want to asked that new device driver need to be added to an image? And i can apply the new driver directly or not?

EX0-101 practice exam | 642-845 practice exam | 000-330 practice exam