Creating threads -Block in accept !
hello friends,
I have several clients and for each i open one thread.The thread does the reading writing stuff. My code worked fine when i started the server first and then the client. But now my requirement is to start the client first.In that case the same code blocks after the first client has been served.Is accept() blocking? Here is my code..
/********Server*************/
void fuction()
{
.......
....... //tcp socket created
for(i=0;i<nthreads;i++)
{
newsok=accept(tcpsok,(struct sockaddr*)&cli_addr,&cli_len);
if(newsok<0)
{
printf("\n Error in accept function ");
exit(0);
}
else
printf("\n Accept OK");
pthread_create(&tid_produce[i],NULL,&produce,(void *)newsok);
}
}
The produce function in turn calls another function.Plz help me out!!
|