Click here to Skip to main content
Rate this: bad
good
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?
Or
Does it combine all the data together before sending?
Or
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
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
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 562
1 Sergey Alexandrovich Kryukov 484
2 Maciej Los 325
3 DamithSL 233
4 Mathew Soji 195
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 6 Mar 2013
Copyright © CodeProject, 1999-2014
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