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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:58:58+00:00 2026-05-16T06:58:58+00:00

So, the code I started with and which works (with important caveats below) int

  • 0

So, the code I started with and which works (with important caveats below)

int reply_length = boost::asio::read(*m_socketptr, boost::asio::buffer((char*)reply, 6));

This works, I get the header which I then decode and follow up with another read which gets me my message and then I loop back to the top and read another header. This pegs my CPU at 100% so I want to replace the header read above with something like the following:

m_socketptr->async_read_some(boost::asio::buffer(m_data, 6), boost::bind(&CSListener::handleRead, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));

or

boost::asio::async_read(*m_socketptr, boost::asio::buffer(m_data, 6), boost::bind(&CSListener::handleRead, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));

Either way I code it, the handleRead method is not ever getting called. Help!?

TIA

  • 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-16T06:58:59+00:00Added an answer on May 16, 2026 at 6:58 am

    I assume you have created an io_service somewhere in your code? You need to call its io_service.run() or io_service.run_one() to make it work. If you need it to be async, then run_one() is you man; put a call to it in you app’s/thread’s main loop.

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

Sidebar

Related Questions

Ive inherited some code which started out as an Android project but really is
EDIT: The correct version of the code which works can be found at :
I have following code which works fine, however when I updated to Lion I
Hi i have the following code which works fine in my machine but when
I started using Padre and while working on a particular program which works just
Some assertions in my code just started acting strangely, and I was wondering if
C++ code (Visual studio started with devenv /useenv (x64) and isWOW64 is false) DWORD64
I have just started to code for Mac OS X and I'm very excited
I've got a source code file that started as a copy of some sample
I have just installed C# 2008 Express Edition 2008 and started writing code. My

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.