+2020-07-26  Eli Zaretskii  <eliz@gnu.org>
+
+       * configure.ac (AC_CHECK_HEADERS): Check for sys/socket.h and
+       ws2tcpip.h.  When checking whether socklen_t type is defined, use
+       ws2tcpip.h if it is available and sys/socket.h isn't.
+       * configure: Regenerate.
+       * config.in: Regenerate.
+
 2020-07-25  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        PR fortran/23051
 
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
+/* Define to 1 if you have the <sys/sockets.h> header file. */
+#undef HAVE_SYS_SOCKETS_H
+
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #undef HAVE_SYS_SOCKET_H
 
 /* Define to 1 if you have the `wresize' function. */
 #undef HAVE_WRESIZE
 
+/* Define to 1 if you have the <ws2tcpip.h> header file. */
+#undef HAVE_WS2TCPIP_H
+
 /* Define to 1 if you have the `XML_StopParser' function. */
 #undef HAVE_XML_STOPPARSER
 
 
 done
 
 
+for ac_header in sys/sockets.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/sockets.h" "ac_cv_header_sys_sockets_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_sockets_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SOCKETS_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in ws2tcpip.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "ws2tcpip.h" "ac_cv_header_ws2tcpip_h" "$ac_includes_default"
+if test "x$ac_cv_header_ws2tcpip_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_WS2TCPIP_H 1
+_ACEOF
+
+fi
+
+done
+
+
 # ------------------------- #
 # Checks for declarations.  #
 # ------------------------- #
 # ------------------ #
 
 ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/types.h>
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
 
 "
 if test "x$ac_cv_type_socklen_t" = xyes; then :
 
 #endif
 ])
 
+AC_CHECK_HEADERS([sys/sockets.h])
+AC_CHECK_HEADERS([ws2tcpip.h])
+
 # ------------------------- #
 # Checks for declarations.  #
 # ------------------------- #
 
 AC_CHECK_TYPES(socklen_t, [], [],
 [#include <sys/types.h>
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
 ])
 
 # ------------------------------------- #
 
+2020-07-26  Eli Zaretskii  <eliz@gnu.org>
+
+       * configure.ac (AC_CHECK_HEADERS): Add ws2tcpip.h.
+       When checking whether socklen_t type is defined, use ws2tcpip.h if
+       it is available and sys/socket.h isn't.
+       * configure: Regenerate.
+       * config.in: Regenerate.
+
 2020-07-22  Pedro Alves  <pedro@palves.net>
 
        * inferiors.cc (switch_to_process): New, moved here from
 
 /* Define to 1 if `vfork' works. */
 #undef HAVE_WORKING_VFORK
 
+/* Define to 1 if you have the <ws2tcpip.h> header file. */
+#undef HAVE_WS2TCPIP_H
+
 /* Define to the address where bug reports for this package should be sent. */
 #undef PACKAGE_BUGREPORT
 
 
 fi
 
 
-for ac_header in termios.h sys/reg.h string.h           sys/procfs.h linux/elf.h                fcntl.h signal.h sys/file.h             sys/ioctl.h netinet/in.h sys/socket.h netdb.h           netinet/tcp.h arpa/inet.h
+for ac_header in termios.h sys/reg.h string.h           sys/procfs.h linux/elf.h                fcntl.h signal.h sys/file.h             sys/ioctl.h netinet/in.h sys/socket.h netdb.h           netinet/tcp.h arpa/inet.h ws2tcpip.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
 
 
 ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/types.h>
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
 
 "
 if test "x$ac_cv_type_socklen_t" = xyes; then :
 
                 sys/procfs.h linux/elf.h dnl
                 fcntl.h signal.h sys/file.h dnl
                 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
-                netinet/tcp.h arpa/inet.h)
+                netinet/tcp.h arpa/inet.h ws2tcpip.h)
 AC_FUNC_FORK
 AC_CHECK_FUNCS(pread pwrite pread64)
 
 
 AC_CHECK_TYPES(socklen_t, [], [],
 [#include <sys/types.h>
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
 ])
 
 case "${target}" in