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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:20:41+00:00 2026-06-03T02:20:41+00:00

I am trying to write my own asynchronous network client using boost::asio. One of

  • 0

I am trying to write my own asynchronous network client using boost::asio. One of the things I am observing in the examples available is the lack of clarity on whether to create a single io_service, resolver and query object or to create new instances of these objects for every connection that I am creating.

I have a client which will only contact a specific server (unique ip & host) but will do this several 100 times a day.

I am planning to have my own network class and in the class itself I have io_service, resolver, query and socket variables all set up at the time of constructing the object.

myclient::myclient() : io_service_(), resolver_(io_service_),
  query_(tcp::v4(), host_, port_), socket_(io_service_) 
{
}

//...

resolver.async_resolve_();
io_service_.reset();
io_service_.run_one();

Does this look okay?

  • 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-03T02:20:43+00:00Added an answer on June 3, 2026 at 2:20 am

    You should try and limit yourself to one io_service for the process that you have described above the io_service class is thread-safe so can be used by many threads at once to dispatch work. Have a quick read of the io_service class documentation where there are some examples of use at the bottom.

    Also have a look at the chat client example and note how the io_service is created in the main function and then passed by reference to the chat_client class.

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

Sidebar

Related Questions

I am trying to write my own edit-in-place using jQuery. My code is something
I'm trying to write my own modal popup window using a jQuery function. However,
Java, i was trying to write my own STUN client, but it seems like
I am trying to write my own LightWeight MVC for .Net 2.0 using NHaml
I'm trying to learn a few things about PHP and write my own template
I'm trying to write my own version of connected components discovery using the breadth-first
I'm trying to write my own fade-ins and fade-outs using the AVAudioPlayer as a
I'm trying to write my own text editor in C using gtk+-2.0 & gtksourceview-2.0.
I'm trying to write my own toy My Toy Language -> MSIL compiler in
I am trying to write our own RIA services provider to expose data from

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.