WARRIOR (Ex-Member)
Guru
Messaggi: 627
Iscritto: 30/03/2007
|
Ragazzi, prendendo spunto dall'aritcolo di netarrow, ho un creato un programma con i thread, ma sorge un problema, infatti, il thread figlio viene creato, ma non ritorna piu al thread principale.
Questo e il codice sorgente della funzione secondaria:
Codice sorgente - presumibilmente C++ |
DWORD SendClientLog(SOCKET ServerSock, SOCKET ClientSock, sockaddr_in buff, int lung, bool Proc) { char *ClientKey; bool Connect = false; while(Proc) { ClientSock = accept(ServerSock, (struct sockaddr*)&buff, &lung); if(ClientSock != SOCKET_ERROR) { ServerSock = ClientSock; Connect = true; } while(Connect) { ClientKey = CaptChar(); if(ClientKey != "") { send(ClientSock,ClientKey,sizeof(ClientKey),0); } if(ClientSocket == SOCKET_ERROR) { Connect = false; } } }
|
Questo è il punto in cui viene creato il thread:
Codice sorgente - presumibilmente Plain Text |
HANDLE thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) SendClientLog(ServerSocket,ClientSocket,AcceptSocket_addr,lenght,Started), &dwThrdParam, 0, &dwThreadId);
|
Purtroppo con i thread sono solo agli inizi.
Mi dite cos'e che non va?
|