From 214caad089b620f2b210c0948b1526d64932a256 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 3 Jun 2020 15:08:16 +0100 Subject: win32: fix networking problems The subprocess that handles incoming connections for httpd didn't work. It has an accepted connection on stdin and calls getpeername() to obtain its details, but getpeername() didn't initialise networking. ssl_client only seems to deal with file descriptors. Expose init_winsock() again and call it from ssl_client. --- win32/net.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'win32') diff --git a/win32/net.c b/win32/net.c index 880b807b7..33dc837fa 100644 --- a/win32/net.c +++ b/win32/net.c @@ -10,7 +10,7 @@ int inet_aton(const char *cp, struct in_addr *inp) return 1; } -static void init_winsock(void) +void init_winsock(void) { WSADATA wsa; static int initialized = 0; @@ -134,8 +134,10 @@ int mingw_accept(int sockfd1, struct sockaddr *sa, socklen_t *sz) #undef getpeername int mingw_getpeername(int fd, struct sockaddr *sa, socklen_t *sz) { - SOCKET sock = (SOCKET)_get_osfhandle(fd); + SOCKET sock; + init_winsock(); + sock = (SOCKET)_get_osfhandle(fd); if (sock == INVALID_SOCKET) { errno = EBADF; return -1; -- cgit v1.2.3-55-g6feb