If I have a function that's main purpose is to write(); to a client that expects a read(); in a function, do I want my select(); to use the read or write argument of the function call?
Example:
What this will do is write to the client once and then hang (which is obviously something wrong in the setup I have with select).Code:int displayMenu(int clientSock){ fd_set writefds; fd_zero(&writefds) fd_set(clientsock,&writefds); if(select(clientsock+1,NULL,&writeds,NULL,NULL)){ for(int i =0;i<course_amount;i++) { write(clientsock,courses[i].coursecode); fflush(stdout); } return 0; }
What step/idea am I missing out on when I need to use select();
The hang is fixed if I cheat and useafter the write();Code:sleep(1);



LinkBack URL
About LinkBacks



