Create an istream from an fd?

N

Nobody

Descriptors are used where the 'file' isn't a regular file (or in the
case of popen, a pipe). A FILE* isn't much use for a socket or a door
for instance.

I'm unfamiliar with "doors", but FILE* is perfectly useful for stream
(e.g. TCP) sockets. It's not useful for datagram (e.g. UDP) sockets, or if
you need to use send/sendto/sendmsg in place of write() (likewise for
reading).
 
I

Ian Collins

I'm unfamiliar with "doors",
http://en.wikipedia.org/wiki/Doors_(computing)

but FILE* is perfectly useful for stream
(e.g. TCP) sockets. It's not useful for datagram (e.g. UDP) sockets, or if
you need to use send/sendto/sendmsg in place of write() (likewise for
reading).

Yes, but going back the the original point, if a file descriptor has to
be be converted to a FILE* by non-standard means, why not just provide a
non-standard istream constructor that uses a file descriptor? There's
little point going though two conversions.
 
N

Nobody

Yes, but going back the the original point, if a file descriptor has to
be be converted to a FILE* by non-standard means, why not just provide a
non-standard istream constructor that uses a file descriptor? There's
little point going though two conversions.

The FILE* may have been obtained from an external library, or a FILE*
may be required by an external library.

Creating a streambuf atop a descriptor which is also used for a FILE*
means that you now have to keep both sets of buffers in sync.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,361
Latest member
eitamoro

Latest Threads

Top