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 7612147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:50:13+00:00 2026-05-31T01:50:13+00:00

I want to program a HTTP client with boost. I could use the asynchronous

  • 0

I want to program a HTTP client with boost. I could use the asynchronous model if I manage to do the following:

  • In a first step, send the request to the server.
  • In a second step, either read the the response that has already arrived or wait synchronously until it arrives.

This is a class that looks similar to what I have produce:

class HTTPClient {
public:
    void sendTheRequest(...) {
        // Send the HTTP request
    }

    std::string getTheResponse(...) {
        // return the already (asynchronously) received response, or wait for it
        // in this function
    }
}

Can someone point out how to realize this? I fear I am lacking the knowledge in boost.

Edit for clarification: The method sendTheRequest will be called at a point. Maybe directly after it getTheResponse will be called, but this can also happen some (milli)seconds later. Thats why I want to send the request asynchronously, but need to wait for it synchronously too.

  • 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-31T01:50:15+00:00Added an answer on May 31, 2026 at 1:50 am

    Mabye a bit late, but I think this should do it. std::future::get returns the value of the send_request_function or waits if that didn’t return yet and returns it after it has completed.

    class HTTPClient {
    public:
        void sendTheRequest(...) {
            // Send the HTTP request
            f = std::async(std::launch::async, send_request_function, args ...);
    
        }
    
        std::string getTheResponse(...) {
            // return the already (asynchronously) received response, or wait for it
            // in this function
            return f.get();
    
        }
    private:
        std::future<std::string> f;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the java.util.Preferences API but I don't want my program to
I want to develop a program for MCB1700 evaluation board. Client software of PC
I'm trying to send a HTTP GET request with UDP (since the reply from
I need to create a program that receives HTTP request and forwards those requests
I'm working on a client-server program for the first time, and I'm feeling woefully
I want to parse the HTML of a website in my C# program. First,
I want my program to change its window's caption in response to various user
I want to program a board game (similar to checkers) for the iPhone. Would
I want to program something in both C# and F#. I have partial classes
I want my program always know all of the mountpoints. After a quick google

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.