title: Should i pass unique OVERLAPPED structure for each WSASend call , in this case?
body: <p>I have a list of sockets.(Opened connections)</p>
  
  <p>I have n worker threads.</p>
  
  <p>Thread loop:</p>
  
  <pre><code>while (1)
      {
          _this.result = GetQueuedCompletionStatus(a_server.server_iocp, &amp;_this.numberOfBytesTransfered,
              &amp;_this.completionKey, (OVERLAPPED**)&amp;_this.iocp_task, INFINITE);
    ...
  }
  </code></pre>
  
  <p>I have this simple struct:</p>
  
  <pre><code>struct iocp_send_global :public iocp_task&lt;IOCP_SEND_GLOBAL&gt; {
    OVERLLAPED ov; //overlapped struct at top
    std::atomic_uint32_t ref;
  
  bool decr_ref(){ return ref.fetch_sub(1, std::memory_order_acq_rel) == 1;}
  
  
  //packet data here
  }
  
  ...
  </code></pre>
  
  <p>This is the 'Broadcast' function:</p>
  
  <pre><code>iocp_send_global * packet = new iocp_send_global;
  
  [set packet data here]
  
  for(int i=0;i&lt;connectionsCount;++i){
      WSASend(connections[i],...,&amp;packet,...); //posting same packet to all connections
  }
  </code></pre>
  
  <p>I want to do this in the worker loop after GetQueuedCompletionStatus call returns with the overlapped result;</p>
  
  <pre><code>    if (_this.iocp_task-&gt;type == IOCP_SEND_GLOBAL) {
                      auto* task = (iocp_send_global*)_this.iocp_task;
  
                      if (!task-&gt;decr_ref()) {
                          _this.iocp_task = nullptr;
                          //dont delete the task yet, 
                          //all send post must finish first 
                          //[all posts share the same buffer]
                      }
                      else {
                      //delete the task containing the send data after all send posts finished
                         delete _this.iocp_task;
                         _this.iocp_task = nullptr;
                      }
  
  }
  </code></pre>
  
  <p>From what i read on Microsoft WSASend documentation each WSASend overlapped call sould have its own OVERLAPPED structure passed, but is that valid when i WSASend the same buffer?</p>
  
  <p>Thank you!</p>