I read the docs on beginsend and endsend. it's definitely the fact that the OS will batch packets, and if there's not enough room in the tcp/ip packet for the entire packet, endsend will return with the actual number of bytes sent, instead of starting a second tcp/ip packet to send the rest of the packet.
There are zero examples on how to actually do this that i can find. i've figured out that i can compare the result of endsend with the sendbuffersize in the callback, but i don't have a working example of how to do a second beginsend, and see no obvious way to fetch the send buffer itself, which is what's needed to actually do a second BeginSend.
I'm testing to set Sock.NoDelay to true, which should just stop this from happening, but i'd rather actually implement a real solution that allows the Nagle Algorithm to run, and actually sends the rest of the packet.
i looked at your code. it's using send, not beginsend for one, and you are most likely using it in blocking mode, so it guarantees that the entire packet gets sent.
And I had to read the MS documentation on EndSend to work out that this can happen, and that there's no way to put EndSend in blocking mode.
So the fix is to either
a) switch from beginsend+callback to send
b) disable nagle algorithm by setting NoDelay to true on the socket.
c) somehow make the callback call beginsend again to send the rest of the packet if it was only partially sent. Pretty much every single code example i can find of EndSend doesn't bother with this. It usually works fine.
I'm testing b), since it's a one line fix/ Doing a) will probably solve the issue completely, but will also lower performance, and reduce the efficiency of the nagle algorithm. Hence me asking if someone actually knows how to do C.
Hmm. putting nodelay everywhere didn't seem to fix it.
What IS the actual packet size limit for the client? I'm not seeing it in the source you linked, just a 4096 byte buffer on recieving.
I know windows will send bigger tcp/ip packets than that.
I suspect i just need to switch from BeginSend to Send everywhere in the code to actually fix it for multicore. ther are at least three DIFFERENT places.
What actually IS the size limit for conquer packets?
There are zero examples on how to actually do this that i can find. i've figured out that i can compare the result of endsend with the sendbuffersize in the callback, but i don't have a working example of how to do a second beginsend, and see no obvious way to fetch the send buffer itself, which is what's needed to actually do a second BeginSend.
I'm testing to set Sock.NoDelay to true, which should just stop this from happening, but i'd rather actually implement a real solution that allows the Nagle Algorithm to run, and actually sends the rest of the packet.
i looked at your code. it's using send, not beginsend for one, and you are most likely using it in blocking mode, so it guarantees that the entire packet gets sent.
And I had to read the MS documentation on EndSend to work out that this can happen, and that there's no way to put EndSend in blocking mode.
So the fix is to either
a) switch from beginsend+callback to send
b) disable nagle algorithm by setting NoDelay to true on the socket.
c) somehow make the callback call beginsend again to send the rest of the packet if it was only partially sent. Pretty much every single code example i can find of EndSend doesn't bother with this. It usually works fine.
I'm testing b), since it's a one line fix/ Doing a) will probably solve the issue completely, but will also lower performance, and reduce the efficiency of the nagle algorithm. Hence me asking if someone actually knows how to do C.
Hmm. putting nodelay everywhere didn't seem to fix it.
What IS the actual packet size limit for the client? I'm not seeing it in the source you linked, just a 4096 byte buffer on recieving.
I know windows will send bigger tcp/ip packets than that.
I suspect i just need to switch from BeginSend to Send everywhere in the code to actually fix it for multicore. ther are at least three DIFFERENT places.
What actually IS the size limit for conquer packets?