Click here to Skip to main content
11,924,800 members (58,142 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ Windows Sockets
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 20: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 | Mobile
Web03 | 2.8.151125.3 | Last Updated 6 Mar 2013
Copyright © CodeProject, 1999-2015
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