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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:05:05+00:00 2026-05-11T12:05:05+00:00

In the boost examples in the documentation, tcp:iostream is used to very simply send

  • 0

In the boost examples in the documentation, tcp:iostream is used to very simply send streams over the network. In other examples write() is used to write data to the socket instead with a bit more code involved.

What is the difference between those 2 methods? Pros and cons? Is there something else that should be used instead ?

  • 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. 2026-05-11T12:05:06+00:00Added an answer on May 11, 2026 at 12:05 pm

    I’ve never used the boost API, so reader beware… 😉

    The tcp::iostream appears to allow you to interact with the socket with a stream-like interface. This approach abstracts the complexities associated with socket programming, so it would be preferable especially if you are new to socket programming. It makes a lot of sense for TCP-based data sharing. It is especially convenient if you are doing very simple data exchanges, such as request/response.

    However, there are cases where you need lower-level control over the data exchange. If your receiver receives a bunch of messages at the same time, you may prefer to read each message from the socket instead of processing them after the fact from the iostream. On the sender side, if your messages are structured as objects, it is often easier just to send the object instead of first converting the object to a stream. The read/write functionality would be preferable in this case.

    From my own (non-boost) socket programming experience, I usually prefer dealing with the lower-level functions since it gives me more flexibility even though it is slightly more complex. I hope that helps.

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

Sidebar

Related Questions

Boost.asio documentation doesn't support any ftp examples. `boost::asio::io_service io_service; tcp::resolver resolver(io_service); tcp::resolver::query query(www.boost.org, http);
I'm using boost::property_tree . The documentation is very vague and overall unhelpful for the
I ran across enable_shared_from_this while reading the Boost.Asio examples and after reading the documentation
I've been looking boost::tokenizer, and I've found that the documentation is very thin. Is
I am trying to implement one of the first examples from boost::random documentation in
I find such examples in Boost code. namespace boost { namespace { extern C
Boost library is full of examples and tests and I would like to build
Boost.Asio documentation suggests the following exception handling pattern : boost::asio::io_service io_service; ... for (;;)
From the documentation on the boost site for lexical cast it states that when
I am going through the boost::asio examples. I am looking at Example 4 What

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.