Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipes to C++ Streams

is it possible to turn pipes genereated via pipe() on a POSIX-system into std::istreams and std::ostreams? if yes, how?

i would prefer to use << and >> instead of read() and write()

thanks in advance

like image 956
M3t0r Avatar asked Sep 10 '10 23:09

M3t0r


People also ask

What is a pipe C?

A pipe is a system call that creates a unidirectional communication link between two file descriptors. The pipe system call is called with a pointer to an array of two integers.

How are stream pipes different from pipes?

In most cases, clists and streams are used to implement a portion of the link between a user process (specifically, a file descriptor) and a character device driver (for example, a serial port or a pty). Pipes are also a queue, but they link user processes (specifically, a pair of file descriptors).

Is a pipe a stream?

A pipe is a communication channel between two processes. It has a writing end and a reading end. When on open one of these two end, one get a (writing or reading) stream. So in a first approximation there is a stream at each end of a pipe.

What is the source of streams piping?

, that implement the input and output components of a pipe. Pipes are used to channel the output from one program (or thread) into the input of another. Piped input and output streams are convenient for methods that produce output to be used as input by someone else.


1 Answers

There are non-standard constructors which take file descriptor number or FILE*. See http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-api-4.5/a00074.html#a777faeb6849444b4663d1cbe543e1ae3

like image 193
liori Avatar answered Sep 24 '22 02:09

liori