summaryrefslogtreecommitdiff
path: root/src/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/socket.c b/src/socket.c
index fe813f5..47c7e38 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -1,6 +1,6 @@
/*
* Socket-related functions
- * Copyright Jan Engelhardt, 2021
+ * Copyright Jan Engelhardt, 2026
*
* This file is part of libHX. libHX is free software; you can
* redistribute it and/or modify it under the terms of the GNU Lesser
@@ -10,6 +10,10 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#define _POSIX_C_SOURCE 999900L /* cygwin-need:freeaddrinfo */
+#ifdef __OpenBSD__
+# define _BSD_SOURCE
+#endif
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
@@ -262,11 +266,11 @@ int HX_local_listen(const char *path)
struct sockaddr_un u;
if (strlen(path) >= sizeof(u.sun_path))
return -EINVAL;
- u.sun_family = AF_LOCAL;
+ u.sun_family = AF_UNIX;
strcpy(u.sun_path, path);
struct addrinfo r = {};
r.ai_flags = AI_PASSIVE;
- r.ai_family = AF_LOCAL;
+ r.ai_family = AF_UNIX;
r.ai_socktype = SOCK_STREAM;
r.ai_addrlen = sizeof(u) - sizeof(u.sun_path) + strlen(u.sun_path) + 1;
r.ai_addr = reinterpret_cast(struct sockaddr *, &u);
@@ -289,7 +293,7 @@ int HX_local_listen(const char *path)
if (!S_ISSOCK(sb.st_mode))
return -ENOTSOCK;
- int testfd = socket(AF_LOCAL, SOCK_STREAM | PLATFORM_SKFLAGS, 0);
+ int testfd = socket(AF_UNIX, SOCK_STREAM | PLATFORM_SKFLAGS, 0);
if (testfd < 0)
return -errno;
ret = connect(testfd, r.ai_addr, r.ai_addrlen);