Cross-platform (linux/Win32) nonblocking C++ IO on stdin/stdout/stderr

I'm trying to find the best solution for nonblocking IO via stdin/stdout with the following characteristics:

  • As long as there is enough data, read in n-sized chunks.
  • If there's not enough data, read in a partial chunk.
  • If there is no data available, block until there is some (even though it may be smaller than n).

The goal is to allow efficient transfer for large datasets while processing 'control' codes immediately (instead of having them linger in some partially-filled buffer somewhere).

I know I can achieve this by using threads and a istream::get() loop, or by writing a bunch of platform-specific code (since you can't select() on file handles in windows)... ((There is also istream::readsome() which seems promising, but the only results I can find on google were of people saying it doesn't actually work well.))

Since I haven't done much coding w/ these APIs, perhaps there is a better way.


Maybe boost::asio can be of use for you?

Need Your Help

Using VBA Excel to navigate a website by changing dropdown value

internet-explorer excel-vba drop-down-menu

I am writing an Excel macro that will navigate to a utility company website and then download all of the statements linked to that account. To get to the statement download page, I need to navigate...

Backslash '\' in console.log() not appearing

javascript jquery

I'm trying to use a back slash in console.log() and within <p></p> but it seems that when the page loads, all back slashes are removed.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.