Click here to Skip to main content
15,886,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to know how WSASend works internally when dealing with multiple WSABUF buffers.

Does it loop through each, sending only the data inside the current buffer?
Or
Does it combine all the data together before sending?
Or
Another method?

I am using Overlapped.

C++
int nBytesSent = WSASend(Socket, (WSABUF*)Buf, BufferCount, &NumberOfBytesSent, 0, &Overlapped, NULL);
Posted

1 solution

Well, please read http://msdn.microsoft.com/en-us/library/windows/desktop/ms742203%28v=vs.85%29.aspx[^] , and if are patient enought, you can reach point where it is written:

"However, the posted buffers are guaranteed to be sent in the same order they are specified."

Obviously, nothing else would make sense.
 
Share this answer
 
Comments
Alistair Budd 6-Mar-13 2:26am    
Thanks, It is working as expected. But how does it work internally. Does it create another block of memory to transfer the data into or does it loop through the buffers. If it creates a buffer internally then it is better for me to force mine into one large block. I know it sounds like it loops through, but with out checking the assembly code I cann know for sure. Do you know where to get the source code for this routine?
jan.mach71 6-Mar-13 2:54am    
Well, in doc again, you can see "This array must remain valid for the duration of the send operation." and in case of overlapped it continues until completion routine gets called. On the other hand, what stops you from deleting WSABUF array and/or buffers it's pointing to just after sending to see if application crashes? We can break in order to learn how it works. From doc, I would guess, that deleting of WSABUF array does not do any harm, but deleting buffers would crash it. Could you confim?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900