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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:08:22+00:00 2026-06-14T23:08:22+00:00

I am using boost::asio to implement network programming and running into timing issues. The

  • 0

I am using boost::asio to implement network programming and running into timing issues. The issue is currently most with the client.

The protocol initially begins by the server returning a date time string to the user, and the client reads it. Up to that part it works fine. But What I also want is to be able to write commands to the server which then processes them. To accomplish this I use the io_service.post() function as shown below.

io_service.post(boost::bind()); // bounded function calls async_write() method. 

For some reason the write tries happens before the initial client/server communication, when the socket has not been created yet. And I get bad socket descriptor error.

Now the io_service’s run method is indeed called in another thread.

When I place a sleep(2) command before post method, it work fine.

Is there way to synchronize this, so that the socket is created before any posted calls are executed.

  • 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-14T23:08:23+00:00Added an answer on June 14, 2026 at 11:08 pm

    When creating the socket and establishing the connection using boost::asio, you can define a method to be called when these operations have either completed or failed. So, you should trigger your “posted call” in the success callback.

    Relevant methods and classes are :

    boost::asio::ip::tcp::resolver::async_resolve(...)
    boost::asio::ip::tcp::socket::async_connect(...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Boost::asio to implement a client/server applicaion. The client code below is
I am trying to write my own asynchronous network client using boost::asio. One of
So I am doing a lot of high performance network programming using Boost::Asio (or
I have successfully implemented a network application in visual CLR project using boost.asio. but
I tried to make an asynchronous UDP client using boost::asio I get some code
I'm just trying to implement a really really small RTSP Client with Boost Asio.
I am using boost::asio to make a socket network. The library has a number
I wrote a small tcp client using boost::asio, providing the following function: typedef boost::function<void(const
There is a client/server application written using Boost's ASIO (Boost v.1.48) + OpenSSL (v.1.0.0d).
I have a very simple server/client performance test using boost::asio on Windows and it

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.