File: tcpdefines.h

package info (click to toggle)
amqp-cpp 4.3.27-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,384 kB
  • sloc: cpp: 10,021; ansic: 191; makefile: 95
file content (27 lines) | stat: -rw-r--r-- 548 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

/**
 * No MSG_NOSIGNAL on OS X.
 * Avoid SIGPIPE by using sockopt call.
 */
#ifdef MSG_NOSIGNAL
# define AMQP_CPP_MSG_NOSIGNAL MSG_NOSIGNAL
#else
# define AMQP_CPP_MSG_NOSIGNAL 0
# ifdef SO_NOSIGPIPE
#  define AMQP_CPP_USE_SO_NOSIGPIPE
# else
#  error "Cannot block SIGPIPE!"
# endif
#endif

#ifdef AMQP_CPP_USE_SO_NOSIGPIPE
/**
 * Ignore SIGPIPE when there is no MSG_NOSIGNAL.
 */
inline void set_sockopt_nosigpipe(int socket)
{
    int optval = 1;
    setsockopt(socket, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval));
}
#endif