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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:53:02+00:00 2026-05-27T17:53:02+00:00

How can I listen to two socket simultaneously using boost::asio? I think there shouldn’t

  • 0

How can I listen to two socket simultaneously using boost::asio? I think there shouldn’t be two io_service. Should I resolve two queries for two acceptors to listen to two sokets? Supposed the two sockets are:

127.0.0.1:7001
127.0.0.2:7001
  • 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-27T17:53:02+00:00Added an answer on May 27, 2026 at 5:53 pm

    You are correct in using one asio io_service. (You are of course allowed to use as many as you would like, but it’s more efficient to just use one since it blocks in a thread and you avoid unnecessary context switching. Also, you can call io_service::run from multiple threads should you wish to use multiple processors.)

    Encapsulate the acceptor and the socket in a class as is demonstrated in many asio examples, and pass the io_service to the class constructor by reference. You can then bind the acceptor to the desired address, listen and call async_accept in a class method that you call.

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

Sidebar

Related Questions

Is there a way how modules can listen to parent application event? My current
How can I listen to data pushed by the server using http connection ?
Is there any notification I can listen to that will alert me that the
I can't seem to find a way to listen for new producer and consumer
i have two spatial xyz file with different resolution how can i contour a
How can a client both subscribe and listen to replies with zeromq? That is,
I have a problem with a c++ socket. I'm using CAsyncSocket from MFC that
I've two pc using VRRP for redundancy. So every PC (Linux) has a physical
I am doing socket programming in Delphi 6 Pro using the ICS (TWSocket) library.
I have a website where users should be able to log in and listen

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.