summaryrefslogtreecommitdiff
path: root/include/hybbx/socket.h
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-08 03:54:55 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-08 03:54:55 +0000
commit20cb29c2f8c5c87bc590896854a20b1473ceb358 (patch)
tree2857f41513a56ad41af97b57362639298aa7f033 /include/hybbx/socket.h
#2
Diffstat (limited to 'include/hybbx/socket.h')
-rw-r--r--include/hybbx/socket.h35
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 */
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com