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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:58:29+00:00 2026-05-18T11:58:29+00:00

The boost asio deadline_timer async_wait function is taking handler of the form : void

  • 0

The boost asio deadline_timer async_wait function is taking handler of the form :

void handler(const boost::system::error_code& error)

How could I define a handler which takes in const boost::system::error_code& error and also an argument of type int ?

boost::asio::deadline_timer t(io_service);

t.async_wait(handler); //I need the async_wait to take in handler which accepts argument boost::system::error_code& error and an int 

void handler(int, const boost::system::error_code& error )//extra int argument

Thanks.

  • 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-18T11:58:29+00:00Added an answer on May 18, 2026 at 11:58 am

    You could use Boost.Bind to provide a value for the first argument :

    t.async_wait(boost::bind(handler, 0, _1));
    

    Here, the handler will be called with a 0 as its first argument and the error_code will simply be forwarded as a second argument.

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

Sidebar

Related Questions

I use boost::asio::buffer to send a message using void Send(const std::string& messageData) { socket.async_write(boost::asio::buffer(messageData),
void Connection::Receive(){ socket_.async_read_some(boost::asio::buffer(read_buffer_), boost::bind(&Connection::handle_Receive, shared_from_this(),boost::asio::placeholders::error)); } void Connection::handle_Receive(const boost::system::error_code& error) { if(!error) { if(read_buffer_.size()
I'm after a better example of the boost::asio::deadline_timer The examples given will always time
I'm using boost::asio, and I have code like this: void CServer::Start(int port) { tcp::acceptor
Just seen this inside <boost/asio.hpp> #ifndef BOOST_ASIO_HPP #define BOOST_ASIO_HPP #if defined(_MSC_VER) && (_MSC_VER >=
I'm trying to run following code: some_sock.async_connect(...); // handle_connect() sets the 'condition' flag boost::asio::deadline_timer
I am attempting to convert the return value of the function boost::asio::async_read to an
class Connection { public: typedef boost::shared_ptr<Connection> pointer; static pointer create(boost::asio::io_service& io_service){return pointer(new Connection(io_service));} explicit
bool Connection::Receive(){ std::vector<uint8_t> buf(1000); boost::asio::async_read(socket_,boost::asio::buffer(buf,1000), boost::bind(&Connection::handler, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); int rcvlen=buf.size(); ByteBuffer b((std::shared_ptr<uint8_t>)buf.data(),rcvlen); if(rcvlen
I've noticed that boost.asio has a lot of examples involving sockets, serial ports, and

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.