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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:08:14+00:00 2026-06-01T20:08:14+00:00

I want to use ifstream to read data from a named piped. I would

  • 0

I want to use ifstream to read data from a named piped. I would like to use its operator>> to read formatted data (typically, an int).
However, I am a bit confused in the way error handling works.

Imagine I want to read an int but only 3 bytes are available. Errors bits would be set, but what will happen to theses 3 bytes ? Will they “disappear”, will they be put back into the stream for later extraction ?

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-06-01T20:08:15+00:00Added an answer on June 1, 2026 at 8:08 pm

    As has been pointed out, you can’t read binary data over an istream.
    But concerning the number of available bytes issue (since you’ll
    probably want to use basic_ios<char> and streambuf for your binary
    streams): istream and ostream use a streambuf for the actual
    sourcing and sinking of the bytes. And streambuf normally buffer: the
    procedure is: if a byte is in the buffer, return it, otherwise, try to
    reload the buffer, waiting until the reloading has finished, or
    definitively failed. In case of definitive failure, the streambuf
    returns end of file, and that terminates the input; istream will
    memorize the end of file, and not attempt any more input. So if the
    type you are reading needs four bytes, it will request four bytes from
    the streambuf, and will normally wait until those four bytes are
    there. No error will be set (because there isn’t an error); you will
    simply not return from the operator>> until those four bytes arrive.

    If you implement your own binary streams, I would strongly recommend
    using the same pattern; it will allow direct use of already existing
    standard components like std::ios_base and (perhaps) std::filebuf,
    and will provide other programmers with an idiom they are familiar with.
    If the blocking is a problem, the simplest solution is just to run the
    input in a separate thread, communicating via a message queue or
    something similar. (Boost has support for asynchronous IO. This avoids
    threads, but is globally much more complicated, and doesn’t work well
    with the classical stream idiom.)

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

Sidebar

Related Questions

i want use some data from a website with web service. i have a
Hi I want read from a hung text file data directly to a string
I have a program that load data from a file using std::ifstream and store
I would like to read an file into a string. I am looking for
i am trying to open a file with ifstream and i want to use
When I use ifstream to read file, I loop over all lines in the
I'm trying to read just the integers from a text file structured like this....
I'm trying to read data in from a binary file and then store in
I want use groovy findAll with my param to filtering closure filterClosure = {
I want use JQuery mobile for the front-end of my mobile application, but I

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.