Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 873577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:57:36+00:00 2026-05-15T10:57:36+00:00

Since I’m not a native English speaker I might be missing something so maybe

  • 0

Since I’m not a native English speaker I might be missing something so maybe someone here knows better than me.

Taken from WSASend‘s doumentation at MSDN:

lpBuffers [in]

A pointer to an array of WSABUF
structures. Each WSABUF structure
contains a pointer to a buffer and the
length, in bytes, of the buffer. For a
Winsock application, once the WSASend
function is called, the system owns
these buffers and the application may
not access them
. This array must
remain valid for the duration of the
send operation.

Ok, can you see the bold text? That’s the unclear spot!

I can think of two translations for this line (might be something else, you name it):
Translation 1 – “buffers” refers to the OVERLAPPED structure that I pass this function when calling it. I may reuse the object again only when getting a completion notification about it.
Translation 2 – “buffers” refer to the actual buffers, those with the data I’m sending. If the WSABUF object points to one buffer, then I cannot touch this buffer until the operation is complete.

Can anyone tell what’s the right interpretation to that line?

And….. If the answer is the second one – how would you resolve it?
Because to me it implies that for each and every data/buffer I’m sending I must retain a copy of it at the sender side – thus having MANY “pending” buffers (in different sizes) on an high traffic application, which really going to hurt “scalability”.

Statement 1:
In addition to the above paragraph (the “And….”), I thought that IOCP copies the data to-be-sent to it’s own buffer and sends from there, unless you set SO_SNDBUF to zero.

Statement 2:
I use stack-allocated buffers (you know, something like char cBuff[1024]; at the function body – if the translation to the main question is the second option (i.e buffers must stay as they are until the send is complete), then… that really screws things up big-time! Can you think of a way to resolve it? (I know, I asked it in other words above).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:57:37+00:00Added an answer on May 15, 2026 at 10:57 am

    The answer is that the overlapped structure and the data buffer itself cannot be reused or released until the completion for the operation occurs.

    This is because the operation is completed asynchronously so even if the data is eventually copied into operating system owned buffers in the TCP/IP stack that may not occur until some time in the future and you’re notified of when by the write completion occurring. Note that with write completions these may be delayed for a surprising amount of time if you’re sending without explicit flow control and relying on the the TCP stack to do flow control for you (see here: some OVERLAPS using WSASend not returning in a timely manner using GetQueuedCompletionStatus?) …

    You can’t use stack allocated buffers unless you place an event in the overlapped structure and block on it until the async operation completes; there’s not a lot of point in doing that as you add complexity over a normal blocking call and you don’t gain a great deal by issuing the call async and then waiting on it.

    In my IOCP server framework (which you can get for free from here) I use dynamically allocated buffers which include the OVERLAPPED structure and which are reference counted. This means that the cleanup (in my case they’re returned to a pool for reuse) happens when the completion occurs and the reference is released. It also means that you can choose to continue to use the buffer after the operation and the cleanup is still simple.

    See also here: I/O Completion Port, How to free Per Socket Context and Per I/O Context?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since hist() of the base R does not report percentages (and the freq=FALSE) does
Since i'm not strong in asp.net, probably my question will sound silly. I've got
Since yesterday suddenly my Eclipse does not work anymore. The error is Failed to
Since OpenGL ES 2.0 is not backward-compatible to OpenGL ES 1.x because of it's
Since i won't be able to post an image here's the link to it
Since Javascript does not have any functionality by itself to communicate over raw sockets
Since I am not getting anywhere with my previous question , I would like
Since I started studying object-oriented programming, I frequently read articles/blogs saying functions are better,
Since Rails is not multithreaded (yet), it seems like a threaded web framework would
Since regular jQuery animations are not fluent on iOS ( .hide() , slideDown() ),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.