Click here to Skip to main content
13,086,120 members (84,106 online)
Rate this:
Please Sign up or sign in to vote.
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?
Does it combine all the data together before sending?
Another method?

I am using Overlapped.

int nBytesSent = WSASend(Socket, (WSABUF*)Buf, BufferCount, &NumberOfBytesSent, 0, &Overlapped, NULL);
Posted 5-Mar-13 19:56pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Well, please read[^] , 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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 6 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100