[ENet-discuss] enet_socket_create() failure on Windows
Alex Cohn
alexcohn at netvision.net.il
Sun Mar 25 01:09:22 PDT 2007
When the enet_socket_create() call fails on Windows due to some
problem in bind() or listen(), there is no way to get the error code.
The reason is that the closesocket() call resets the
WSAGetLastError().
I have changed the file win32.c to store the code:
if (bind....)
{
int err = WSAGetLastError(); // store the actual error code
closesocket (newSocket); // this resets the actual error code
WSASetLastError(err); // report the actual error code
return ENET_SOCKET_NULL;
}
I wonder whether this is the optimal solution (it causes the calling
program be platform, in this case, WinSock - aware). But at least,
this makes it possible to find and report to log files the reasons for
failure.
Your comments will be most appreciated,
Alex Cohn
More information about the ENet-discuss
mailing list