I’ve knocked up some test code along the following lines…
Set up multiple listen servers on ports X to X + 49
Set up 50 clients and connect each of them to a single server on port X to x + 49
The clients send a string to the server they are connected to, with a delay of 200 ms between sends.
All servers echo this string back to their respective client. So client 0 sends “abc”, and all clients receive “abc” back.
This is basically a chat client with all clients logged into the same channel.
The Server(s) work along the following lines…
Anything received goes into a single Work Queue to be acted on.
A single thread processes each item from the Work Queue in order.
Any sends required are placed into a second Send Queue which is serviced by a number of threads.
The threads that service the Send Queue just dequeue an item, serialise it to a single buffer (per thread), and perform a send.
For testing, immediately after the send is performed, I overwrite the byte array that the object was serialised into with character 88, corrupting it.
In total, the server transmits 250000 strings in response to receiving 5000 strings.
I’ve tested with between 1 to 10 threads servicing the send queue, the sweet spot seems to be around 4 threads.
All data appears to be echoed correctly back to the clients with no issues.
From this I’m pretty sure that the NetworkComms library must either be performing a copy of the send buffer internally and using that copy, or it may be waiting until the network stack is finished with the buffer before exiting.
Does this sound about right? Or have i missed something?
- This reply was modified 8 years, 2 months ago by .