View Full Version : Problems with NetGame: unable to create socket handle

10-20-2012, 11:41 PM

I tried to use NetGame and in a console application and that works well.
But after that, i tried it in a normal Win32 Application and i always got the error message: "unable to create socket handle" by using CL_NetGameClient::connect("","4556");
(Server is still a console application, does that matter?).

So i tried it manually with WinSockets (http://msdn.microsoft.com/en-us/library/ms737625%28VS.85%29.aspx)
And it worked :)

I changed the source code in the file win32_socket.cpp as you can see below

: handle(INVALID_SOCKET), close_handle(true), event_handle(0), receive_handle(0), send_handle(0), except_handle(0)
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);

if (iResult != NO_ERROR)
throw CL_Exception("Failure in setting Sockets up!");

after that it worked.

Is this a kind of bug or is there another solution without changing the source code?

thank you, and i hope my english is good enough...

10-21-2012, 07:04 AM
You did not call...

CL_SetupNetwork::CL_SetupNetwork(bool register_resources_only)
if (ref_count > 1) return;

if (register_resources_only == false)
WORD winsock_version = MAKEWORD( 2, 2 );
WSADATA wsaData;
int err = WSAStartup(winsock_version, &wsaData);
if (err != 0)
throw CL_Exception("Failed to initialize winsockets");

10-21-2012, 09:39 AM
oh thank you now it works..., but an evidence in the Tutorial would be helpful