CreateThread and Winsock Question
I was looking at the Winsock FAQ (http://tangentsoft.net/wskfaq/) and they had an example for a simple multi threaded server. I complied it and it worked fine. I then made a new project and made a threaded server class, CServer. When I compiled it the line
CreateThread(0, 0, EchoHandler, (void*)sd, 0, &nThreadID);
generated the error
error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'
None of the functions with this name in scope match the target type
the prototype for the function is
DWORD WINAPI CServer::EchoHandler(void* sd_)
its the exact same as in the example except for the 'CServer::' does anyone have any ideas why this won't work? Thanks in advance
James
Re: CreateThread and Winsock Question
Quote:
Originally posted by jamesbr
CreateThread(0, 0, EchoHandler, (void*)sd, 0, &nThreadID);
generated the error
error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'
None of the functions with this name in scope match the target type
It looks like 'EchoHandler()' is a member function of your class. In this case it needs to be static in order to be used as a thread function. Further explanation can be found in the FAQ...