Kyle_Katarn | Code :
- UINT ServerThread(LPVOID pParam)
- {
- CAsyncSocket server;
- CAsyncSocket client;
- server.Create(25);
- WORD wVersionRequested;
- WSADATA wsaData;
- wVersionRequested = MAKEWORD( 2, 0 );
- if ( WSAStartup( wVersionRequested, &wsaData ) != 0 )
- {
- WSACleanup();
- return 0;
- }
- if(!server.Listen() )
- {
- CString ErrorMessage;
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,WSAGetLastError(),NULL,ErrorMessage.GetBuffer(255),255,NULL);
- ErrorMessage.ReleaseBuffer();
- AfxMessageBox(ErrorMessage);
- WSACleanup();
- return 0;
- }
-
- sockaddr_in from;
- int fromlen=sizeof(from);
- while(true)
- {
- if (server.Accept(client),&from,&fromlen)
- AfxBeginThread(ClientThread,(LPVOID)&client);
- }
- WSACleanup();
- return 0;
- }
|
Où est l'erreur qui fait que Accept plante tout ici ? |