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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:32:56+00:00 2026-05-29T05:32:56+00:00

I have an boost asio server application and I’m struggling with how to transmit

  • 0

I have an boost asio server application and I’m struggling with how to transmit created sockets (e.g. transmit accept socket to the protocol implementation classes that will read/write data down the road)

For example if I make them being transmitted by shared_ptr to different classes that read/write to them it works out. My server has an io_service.run() before exiting the main program and all async operations done on those sockets are performed in there.

EDIT I found out that the problem was not the way I was transmitting socket class. It is possible to keep ownership of these in a class and passing reference down the road. In my case one of the connection classes were being destroyed before async operation handler finished their work.

  • 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-29T05:32:57+00:00Added an answer on May 29, 2026 at 5:32 am

    I think this question actually has nothing to do specifically with asio and could be genericized to “How should I transfer ownership of allocated objects?”.

    And my answer would be: Use std::unique_ptr
    (…for C++11)

    If the receiver of the unique_ptr wants to use a different ownership idiom (like shared_ptr) it’s easy to release from the unique_ptr and turn it into a shared_ptr. The opposite isn’t true. This way, there is no time when your pointer is raw and could be leaked.

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

Sidebar

Related Questions

My client application uses a boost::asio::ip::tcp::socket to connect to a remote server. If the
I have a socket server, written in C++ using boost::asio, and I'm sending data
I have a TCP server using boost asio. I have accepted a socket connection.
I have a TCP server using boost asio. I have accepted a socket connection.
I have a Win32 application that uses boost::asio and openssl library but it seems
I'm writing server using boost.asio. I have read and write buffer for each connection
I have a very simple server/client performance test using boost::asio on Windows and it
I am using boost::asio to create a server application, specifically the UDP APIs. Right
I have a boost::asio based server which works fine, except that I'm trying to
I have written a server based on boost::asio in windows platform. I want to

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.