Windows IOCP - WSASend(). Unclarity regarding the data buffers. RRS feed

  • Question

  • Hi!

    Taken from
    After reading the following two lines I'm a bit confused;

    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.

    Data is copied from the buffer(s) into the transport's buffer.

    See? The 2nd line tells me that the data is being copied to the transport's buffer, meaning, from what I understand, that the original buffer is free for manipulations.

    On the other hand, the 1st line tells me that these buffer(s) that I've sent must be "valid", for the "duration of the send operation".
    Define "valid" and "duration of the send operation"???

    Again, if I understand right;
    "valid" - Buffer cannot be allocated on the stack, otherwise when the function exits, this memory is no longer "valid". (variable scope).

    "duration of the send operation" - Really not clear. Does this mean that I have to wait for the "write complete" completion port notification?

    Please advise, thank you very much!
    This is the information I want to share (=
    Wednesday, August 26, 2009 3:59 AM

All replies

  • It's not guaranteed that the data is copied to the transport provider as soon as the function returns since it's asynchronous, so you must guarantee that the buffer exists with the data until you get the completion notification.
    Ricardo Costa
    • Proposed as answer by RicarDog Sunday, September 13, 2009 5:37 PM
    Sunday, September 13, 2009 5:36 PM