|
-
August 3rd, 2012, 06:33 PM
#2
Re: My send() socket call iis taking its own sweet time
Your code suggests that your architecture uses blocking sockets.
If so, well, blocking sockets by their very nature will block. The block can be frustrating, but it allows you to write code with a very simple and serialized flow logic.
If you cannot tolerate the block, there are two options: re-write using non-blocking sockets, or maintain the use of blocking sockets but re-write into a multithreaded code, with one thread per client.
Both will introduce complications, and you are in the best position to know which one might be more appropriate. For example, if there is significnat coordination amongst the clients, then multithreading might be too difficult.
Without knowing more, with only around 100 clients, the multithreaded approach might be easier than non-blocking sockets. As you start to exceed a few hundred threads, the context switching among threads makes the multithreaded approach impractical, so this architecture would not be easily extensible if you suddenly find that you need to service 1000 clients simultaneously.
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|