aboutsummaryrefslogtreecommitdiff
path: root/src/compat/compat.h
diff options
context:
space:
mode:
authorMatthew Zipkin <pinheadmz@gmail.com>2023-05-26 12:26:43 -0400
committerMatthew Zipkin <pinheadmz@gmail.com>2024-03-01 13:13:07 -0500
commitbae86c8d318d06818aa75a9ebe3db864197f0bc6 (patch)
tree893a4fde71f37fcfab090b216a8f097ce9308fb8 /src/compat/compat.h
parentadb3a3e51de205cc69b1a58647c65c04fa6c6362 (diff)
downloadbitcoin-bae86c8d318d06818aa75a9ebe3db864197f0bc6.tar.xz
netbase: refactor CreateSock() to accept sa_family_t
Also implement CService::GetSAFamily() to provide sa_family_t
Diffstat (limited to 'src/compat/compat.h')
-rw-r--r--src/compat/compat.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 9ff9a335f8..366c648ae7 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -32,6 +32,13 @@
#include <unistd.h> // IWYU pragma: export
#endif
+// Windows does not have `sa_family_t` - it defines `sockaddr::sa_family` as `u_short`.
+// Thus define `sa_family_t` on Windows too so that the rest of the code can use `sa_family_t`.
+// See https://learn.microsoft.com/en-us/windows/win32/api/winsock/ns-winsock-sockaddr#syntax
+#ifdef WIN32
+typedef u_short sa_family_t;
+#endif
+
// We map Linux / BSD error functions and codes, to the equivalent
// Windows definitions, and use the WSA* names throughout our code.
// Note that glibc defines EWOULDBLOCK as EAGAIN (see errno.h).