option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON)
if(ENABLE_UNIX_SOCKETS)
include(CheckStructHasMember)
- check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS)
+ if(WIN32)
+ set(USE_UNIX_SOCKETS ON)
+ else()
+ check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS)
+ endif()
else()
unset(USE_UNIX_SOCKETS CACHE)
endif()
#define USE_WIN32_CRYPTO
#endif
-/* On MinGW the ADDRESS_FAMILY typedef was committed alongside LUP_SECURE,
- so we use it to check for the presence of the typedef. */
-#include <ws2tcpip.h>
-#if !defined(__MINGW32__) || defined(LUP_SECURE)
/* Define to use Unix sockets. */
#define USE_UNIX_SOCKETS
-#if !defined(UNIX_PATH_MAX)
- /* Replicating logic present in afunix.h of newer Windows 10 SDK versions */
-# define UNIX_PATH_MAX 108
- /* !checksrc! disable TYPEDEFSTRUCT 1 */
- typedef struct sockaddr_un {
- ADDRESS_FAMILY sun_family;
- char sun_path[UNIX_PATH_MAX];
- } SOCKADDR_UN, *PSOCKADDR_UN;
-#endif
-#endif
/* ---------------------------------------------------------------- */
/* ADDITIONAL DEFINITIONS */
# define in_addr_t unsigned long
#endif
-#if defined(USE_UNIX_SOCKETS) && defined(WINAPI_FAMILY) && \
- (WINAPI_FAMILY == WINAPI_FAMILY_APP)
- /* Required for sockaddr_un type */
-# include <afunix.h>
-#endif
-
#include <stddef.h>
#include "curl_addrinfo.h"
#define ENABLE_QUIC
#endif
+#if defined(USE_UNIX_SOCKETS) && defined(WIN32)
+# if defined(__MINGW32__) && !defined(LUP_SECURE)
+ typedef u_short ADDRESS_FAMILY; /* Classic mingw, 11y+ old mingw-w64 */
+# endif
+# if !defined(UNIX_PATH_MAX)
+ /* Replicating logic present in afunix.h
+ (distributed with newer Windows 10 SDK versions only) */
+# define UNIX_PATH_MAX 108
+ /* !checksrc! disable TYPEDEFSTRUCT 1 */
+ typedef struct sockaddr_un {
+ ADDRESS_FAMILY sun_family;
+ char sun_path[UNIX_PATH_MAX];
+ } SOCKADDR_UN, *PSOCKADDR_UN;
+# endif
+#endif
+
#endif /* HEADER_CURL_SETUP_H */
strncpy(me.sau.sun_path, unix_socket, sizeof(me.sau.sun_path) - 1);
rc = bind(sock, &me.sa, sizeof(me.sau));
if(0 != rc && errno == EADDRINUSE) {
- struct stat statbuf;
+ struct_stat statbuf;
/* socket already exists. Perhaps it is stale? */
- int unixfd = socket(AF_UNIX, SOCK_STREAM, 0);
+ curl_socket_t unixfd = socket(AF_UNIX, SOCK_STREAM, 0);
if(CURL_SOCKET_BAD == unixfd) {
error = SOCKERRNO;
logmsg("Error binding socket, failed to create socket at %s: (%d) %s",
/* check whether the server is alive */
rc = connect(unixfd, &me.sa, sizeof(me.sau));
error = errno;
- close(unixfd);
+ sclose(unixfd);
if(ECONNREFUSED != error) {
logmsg("Error binding socket, failed to connect to %s: (%d) %s",
unix_socket, error, strerror(error));
goto sws_cleanup;
}
- /* socket server is not alive, now check if it was actually a socket.
- * Systems which have Unix sockets will also have lstat */
+ /* socket server is not alive, now check if it was actually a socket. */
+#ifdef WIN32
+ /* Windows does not have lstat function. */
+ rc = curlx_win32_stat(unix_socket, &statbuf);
+#else
rc = lstat(unix_socket, &statbuf);
+#endif
if(0 != rc) {
logmsg("Error binding socket, failed to stat %s: (%d) %s",
unix_socket, errno, strerror(errno));