blob: 1baa639f1f58b0fa2dabfdc2c1ac57032654a66c (
plain)
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
28
29
30
31
32
33
34
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 */
|