To whom it may concern:
I built shishi-1.0.2 using MinGW and MSYS. All `make check' tests failed with
libshishi: warning: Failed to initialized Windows sockets (2)
I am on Windows 8.1.
There are two problems:
1) Incorrect definition of SOCKET* constants in gl/sockets.h
Your definitions are:#define SOCKETS_1_0 0x100 don't use - does not work on Windows XP
#define SOCKETS_1_1 0x101
#define SOCKETS_2_0 0x200 don't use - does not work on Windows XP
#define SOCKETS_2_1 0x201
#define SOCKETS_2_2 0x202
- wVersionRequested [in]
The highest version of Windows Sockets specification that the caller
can use. The high-order byte specifies the minor version number; the
low-order byte specifies the major version number.
- This means that if you want to request Winsock 2.1 (as you do) wRequested version must be
- 0x0102, not 0x0201. In lib/init.c, where you have
rc = gl_sockets_startup (SOCKETS_2_1);
- you are actually requesting version 1.2.
This leads us to the next problem, which is
2) The test for a compatible version of Winsock is incorrect.
Now let us consider gl_sockets_startup.
err = WSAStartup (version, &data);
if (err != 0)
if (data.wVersion < version)
Suppose that we were requesting Winsock 2.0
on a system that had only 1.1. Then version (the requested version) would be
0x0002 and the available version would be 0x0101. In this case
data.wVersion < version is
0x0101 < 0x0002 which is false, so you would end up accepting Winsock 1.1
even though you wanted to reject it because it less than the 2.0 that you wanted.
You do not need to rearrange the bytes before comparing them. Remember that
WSAStartup must return the version that you requested or a lower one, because
you already told it the highest version that you can accept. Therefore, if the
version that is returned is different from the version that was requested, it must be
less than the version that was requested.
To fix the problem, you must:
a) define the SOCKETS_* constants as follows:
#define SOCKETS_1_0 0x0001
#define SOCKETS_1_1 0x0101
#define SOCKETS_2_0 0x0002
#define SOCKETS_2_1 0x0102
#define SOCKETS_2_2 0x0202