summaryrefslogtreecommitdiffstats
path: root/win/tclWinSock.c
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2002-11-27 22:47:15 (GMT)
committerdavygrvy <davygrvy@pobox.com>2002-11-27 22:47:15 (GMT)
commit3f212f7af44708141173de96925172f3003d49a9 (patch)
tree935587ff3476e07c815dfa20c5463397b7cb1347 /win/tclWinSock.c
parentcbd9f68026f5cb0e3a5c745ae0e4d0171e2b0009 (diff)
downloadtcl-3f212f7af44708141173de96925172f3003d49a9.zip
tcl-3f212f7af44708141173de96925172f3003d49a9.tar.gz
tcl-3f212f7af44708141173de96925172f3003d49a9.tar.bz2
* win/tclWinSock.c: WSAStartup() loaded version comparison
error which resulted in 2.0 looking less than 1.1.
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r--win/tclWinSock.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 72293ad..f314408 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinSock.c,v 1.32 2002/11/27 18:37:28 davygrvy Exp $
+ * RCS: @(#) $Id: tclWinSock.c,v 1.33 2002/11/27 22:47:28 davygrvy Exp $
*/
#include "tclWinInt.h"
@@ -257,6 +257,7 @@ InitSockets()
{
DWORD id;
WSADATA wsaData;
+ int err;
ThreadSpecificData *tsdPtr =
(ThreadSpecificData *)TclThreadDataKeyGet(&dataKey);
@@ -385,19 +386,36 @@ InitSockets()
TclWinConvertError(GetLastError());
goto unloadLibrary;
}
-
+
/*
- * Initialize the winsock library and check the version number.
- * We only ask for the 1.1 interface.
+ * Initialize the winsock library and check the interface
+ * version number. We only ask for the 1.1 interface.
+ *
+ * Note that WSA_VERSION_REQD has major/minor swapped for the API
+ * call (as it is supposed to be) and wsaData.wVersion is
+ * reversed back for the comparison. Also, note that
+ * WSAVERNOTSUPPORTED is not listed in the error table, but
+ * simply gets translated to EINVAL by being out-of-range.
*/
-
- if (winSock.WSAStartup(MAKEWORD(1,1), &wsaData) != 0) {
+
+#define WSA_VERSION_MAJOR 1
+#define WSA_VERSION_MINOR 1
+#define WSA_VERSION_REQD MAKEWORD(WSA_VERSION_MINOR, WSA_VERSION_MAJOR)
+
+ if ((err = winSock.WSAStartup(WSA_VERSION_REQD, &wsaData)) != 0) {
+ TclWinConvertWSAError(err);
goto unloadLibrary;
}
- if (wsaData.wVersion < MAKEWORD(1,1)) {
+ if (((LOBYTE(wsaData.wVersion) << 16) + HIBYTE(wsaData.wVersion))
+ < (WSA_VERSION_MAJOR << 16) + WSA_VERSION_MINOR) {
+ TclWinConvertWSAError(WSAVERNOTSUPPORTED);
winSock.WSACleanup();
goto unloadLibrary;
}
+
+#undef WSA_VERSION_REQD
+#undef WSA_VERSION_MAJOR
+#undef WSA_VERSION_MINOR
}
/*