Suppose the server handles clients in the following manner:
void* handle_request(void* client_sck);
int client_sck;
while((client_sck = accept(...)) != -1)
{
/*
.
.
.
*/
pthread_create(&thr, 0, handle_request, (void*)&client_sck);
}
Is it safe to say that, on each loop iteration, the last argument passed to pthread_create
will be shared among threads? Meaning the second time a around, the client_sck still has the same address from the previous iteration.