Reputation: 111
I am trying to implement client-server socket application in such away that client send some data stream to server , and the server do some computation to the stream and send back the result to client. Here is the rule then:
The client must try to keep the server as busy as possible, by applying this policy: the client must keep sending bytes whenever possible and must receive bytes with lower priority (i.e. only when sending more bytes is impossible(when sending more bytes would block the sending process)). How can I apply this policy. I already implemented client-server application with blocking version.
Upvotes: 2
Views: 215
Reputation: 215201
Zan Lynx's answer is the most widely accepted these days, but there is another option: use separate threads for sending and receiving, and give the sending thread higher priority.
Upvotes: 2
Reputation: 54325
Use non-blocking IO. Particularly read about the select and poll functions.
Upvotes: 3