Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore support for building with Winsock 1.1 (SDL 1.2) #42

Open
wants to merge 1 commit into
base: SDL-1.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions SDLnet.c
Expand Up @@ -106,6 +106,9 @@ void SDLNet_Quit(void)
/* Clean up windows networking */
if ( WSACleanup() == SOCKET_ERROR ) {
if ( WSAGetLastError() == WSAEINPROGRESS ) {
#ifndef __USE_WINSOCK2
WSACancelBlockingCall();
#endif
WSACleanup();
}
}
Expand Down
7 changes: 7 additions & 0 deletions SDLnetsys.h
Expand Up @@ -33,8 +33,15 @@
/* Include system network headers */
#if defined(__WIN32__) || defined(WIN32)
#define __USE_W32_SOCKETS
#ifdef __USE_WINSOCK2
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <winsock.h>
/* NOTE: windows socklen_t is signed
* and is defined only for winsock2. */
typedef int socklen_t;
#endif
#include <iphlpapi.h>
#else /* UNIX */
#ifdef __OS2__
Expand Down
8 changes: 4 additions & 4 deletions VisualC/SDL_net_VS2008.vcproj
Expand Up @@ -51,7 +51,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;__USE_WINSOCK2"
MinimalRebuild="true"
RuntimeLibrary="2"
PrecompiledHeaderFile=".\Debug/SDL_net.pch"
Expand Down Expand Up @@ -138,7 +138,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;__USE_WINSOCK2"
MinimalRebuild="true"
RuntimeLibrary="2"
PrecompiledHeaderFile=".\Debug/SDL_net.pch"
Expand Down Expand Up @@ -229,7 +229,7 @@
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;__USE_WINSOCK2"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
Expand Down Expand Up @@ -316,7 +316,7 @@
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;__USE_WINSOCK2"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
Expand Down
11 changes: 10 additions & 1 deletion configure.ac
Expand Up @@ -82,10 +82,19 @@ AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue)
dnl Figure out which networking libraries to use
case "$host" in
*mingw32ce*)
CFLAGS="$CFLAGS -D__USE_WINSOCK2"
INETLIB="-lws2 -liphlpapi"
;;
*-*-cygwin* | *-*-mingw*)
INETLIB="-lws2_32 -liphlpapi"
AC_ARG_ENABLE(winsock2,
[AS_HELP_STRING([--enable-winsock2],[Build with Winsock 2 instead of 1.1 [default=yes]])],
, enable_winsock2=yes)
if test x$enable_winsock2 = xyes; then
CFLAGS="$CFLAGS -D__USE_WINSOCK2"
INETLIB="-lws2_32 -liphlpapi"
else
INETLIB="-lwsock32 -liphlpapi"
fi
;;
sparc*-*-solaris*)
INETLIB="-lsocket -lnsl"
Expand Down