Click here to Skip to main content
11,802,442 members (70,497 online)
Rate this: bad
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 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 at 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 at 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
0 OriginalGriff 445
1 KrunalRohit 366
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CPallini 230
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,645
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | 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