CreateThread()创建线程传递SOCKET参数


使用CreateThread()创建线程传递SOCKET参数的正确方法如下:

创建线程和传递参数

	SOCKET client;

	client = accept(server, (SOCKADDR*)&clientaddr, &addrsize);

	//...

	HANDLE hThread = CreateThread(NULL,0,do_something,(LPVOID)client,0,NULL);

接收参数

DWORD WINAPI do_something(LPVOID lpParamter){
	
	SOCKET client = (SOCKET)lpParamter;

	// ...
}