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

  • SEARCH
  • Home
  • 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 8335145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:34:37+00:00 2026-06-09T03:34:37+00:00

My main thread creates multiple I/O worker threads. I then initiate an I/O request

  • 0

My main thread creates multiple I/O worker threads. I then initiate an I/O request from my main thread by doing:

{
    ...
    IoRequest *pIoRequest = new IoRequest(m_socket);
    pIoRequest->SetBuffer(vecCommandData); // vector of BYTEs
    pIoRequest->SetOperationType(OP_TYPE_SEND);
    WSASend(m_socket, pIoRequest->GetWsaBuffer(), 1, NULL, 0, pIoRequest, NULL);
    ...
}

At some point in one of my I/O worker threads, the request is completed and my IoRequest object’s buffer is filled with valid response data.

DWORD WINAPI WorkerThreadProc(LPVOID lpParameter)
{
    IoCompletionPort *pIocp = reinterpret_cast<IoCompletionPort*>(lpParameter);    
    ...
    while (true)
    {
        BOOL bReturn = pIocp->GetStatus(&ulCompletionKey, &dwNumberOfBytesTransferred, (LPOVERLAPPED*)&pIoRequest);
        ...
        switch (pIoRequest->GetOperationType())
        {
        ...
        case OP_TYPE_RECEIVE_DATA:
            {
                ...
                // the requested I/O operation has completed and pIoRequest's buffer now contains valid response data!
                break;
            } 
        ...
        }
    }

    return 0;
}

How can I place my main thread in an alertable wait state after calling WSASend() and make it receive the response data whenever it’s ready?

  • 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-06-09T03:34:38+00:00Added an answer on June 9, 2026 at 3:34 am

    In an IOCP server, it’s typically GetQueuedCompletionStatus().

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

Sidebar

Related Questions

Often I create Child threads within the main() as Thread thread = new Thread(new
I want to create a worker thread that isn't the main thread so I
Main thread of application is doing some work. There also exists a timer, which
Apart from main thread, I've ThinkerThread object _thinker whose finished() signal is connected to
I have the main thread from which I start a window using invokeLater .
I want to learn how to create multiple threads with the new C++ standard
I have been creating multiple background threads to parse xml files and recreate new
From my main thread, I launch an image loader method method-A (below). The problem
I have one main thread, and many other background threads. The main usage of
Here's the scenario. I have multiple processor threads reading a value. Only 1 thread

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.