阅读背景:

Pthread服务器编程:如何释放在recv调用中被阻塞的线程以处理来自另一个线程的请求

来源:互联网 

I have a simple server program, written in C on Debian using the pthread lib. The program handles the communication between some clients which want to share files. For each client there is a handler thread. Now, at some point, each thread will block on recv() waiting for any client file requests. If one of the clients asks for a specific file owned, by another client, the server has to get this file from its owner, through its handler thread, and then deliver the file to the client which requested it, through its handler thread. As all the threads are blocked on the recv() calls, how can they be noticed by other threads that they have to request a file to the client they are handling? Is there any way to "interrupt" the recv(), serve the request and then go back to the recv()?I have a simple server program, written in C on




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: