From 20cb29c2f8c5c87bc590896854a20b1473ceb358 Mon Sep 17 00:00:00 2001 From: "info@mode42.com" Date: Sat, 8 Aug 2026 03:54:55 +0000 Subject: #2 --- include/hybbx/socket.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/hybbx/socket.h (limited to 'include/hybbx/socket.h') 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 + +#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 */ -- cgit v1.3.1