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.
mallocing a new argument for each iteration before the call topthread_createthe right move ? @Nic3500 I'm curious about a more simplistic example of an http server rather than a full-blown project. Mostly due to the nature ofpthread_create