diff options
Diffstat (limited to 'include/hybbx/socket.h')
| -rw-r--r-- | include/hybbx/socket.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/hybbx/socket.h b/include/hybbx/socket.h new file mode 100644 index 0000000..1baa639 --- /dev/null +++ b/include/hybbx/socket.h @@ -0,0 +1,35 @@ +#ifndef HYBBX_SOCKET_H +#define HYBBX_SOCKET_H + +#if defined(__linux__) || defined(__GLIBC__) +#define _DEFAULT_SOURCE 1 +#endif + +#include <sys/socket.h> + +#ifndef MSG_NOSIGNAL +#define MSG_NOSIGNAL 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** Suppress SIGPIPE on send() (SO_NOSIGPIPE on BSD/MacOS; noop on Linux). */ +void hybbx_socket_nosigpipe(int fd); + +/** + * Format the peer IP address of a connected socket into @p buf. + * IPv4 dotted-quad or IPv6 colon form (no brackets). + */ +hybbx_result_t hybbx_socket_peer_name(int fd, char *buf, size_t buf_len); + +/** Log bind(2) failure; hints when @c EADDRINUSE (HyBBX already running). */ +void hybbx_socket_log_bind_failure(const char *component, const char *addr, + unsigned port); + +#ifdef __cplusplus +} +#endif + +#endif /* HYBBX_SOCKET_H */ |
