Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #9389

Re: Create an istream from an fd?

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Create an istream from an fd?
Date 2011-08-28 16:04 +1200
Message-ID <9btt20FopsU7@mid.individual.net> (permalink)
References (1 earlier) <j39a3q$6gk$1@dont-email.me> <9bqok6FeijU2@mid.individual.net> <j39ep8$tv5$1@dont-email.me> <9btaq6FopsU5@mid.individual.net> <2be71f2e-9a18-42ab-a7ec-bc7f8ccb215e@i9g2000yqk.googlegroups.com>

Show all headers | View raw


On 08/28/11 11:35 AM, James Kanze wrote:
> On Aug 27, 11:52 pm, Ian Collins<ian-n...@hotmail.com>  wrote:
>> On 08/27/11 12:46 PM, Alf P. Steinbach wrote:
>
>>> On 27.08.2011 01:30, Ian Collins wrote:
>>>> On 08/27/11 11:26 AM, Alf P. Steinbach wrote:
>>>>> On 26.08.2011 17:54, Noah Roberts wrote:
>>>>>> Is there a straight forward of creating an istream out of a file
>>>>>> descriptor? If there is I'd like to use it before going off and
>>>>>> making such a thing.
>
>>>>> Compiler-specific.
>
>>>> Compiler, or platform?
>
>>> Well, to be precise, it's specific to the standard library
>>> implementation. But usually one does not replace the one bundled with
>>> the compiler. So then it's compiler-specific.
>
>> How so?  There aren't any istream constructors or other members that
>> work with file descriptors.  I guess there could be library extensions,
>> but they are part of the "standard" library, are they?
>
>> My point was the notion of a "file descriptor" is platform specific, so
>> any streambuf derivative that uses one would also be platform specific.
>
> It's largely a quality of implementation issue.  As you say,
> there is no portable "file descriptor" type, so the standard
> doesn't provide a constructor for filebuf which takes one.  The
> implementor is left with three choices:
>
>   -- add the necessary constructor, as an extention (provided
>      that this doesn't cause ambiguities with an existing
>      constructor),
>
>   -- offer an additional stream type whose streambuf can be
>      constructed from a file descriptor, or
>
>   -- just ignore the issue.
>
>  From a QoI point of view, the first is preferrable, the second
> is fairly acceptable, and the last is very bad.  From a QoI
> point of view: all are fine according to the standard.

The compilers I use do the first approach, but do it in subtly different 
ways (such as who is responsible for closing the file?).  So I always 
use my own streambuf class.  A specialised streambuf has the further 
advantage of easy customisation for file like entities that aren't 
regular files.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Create an istream from an fd? Noah Roberts <roberts.noah@gmail.com> - 2011-08-26 08:54 -0700
  Re: Create an istream from an fd? Leigh Johnston <leigh@i42.co.uk> - 2011-08-26 17:05 +0100
  Re: Create an istream from an fd? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-26 12:20 -0400
  Re: Create an istream from an fd? Vaclav Zeman <vzeman79@sh.cvut.cz> - 2011-08-26 18:34 +0200
  Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-27 08:48 +1200
  Re: Create an istream from an fd? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-27 01:26 +0200
    Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-27 11:30 +1200
      Re: Create an istream from an fd? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-27 02:46 +0200
        Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 10:52 +1200
          Re: Create an istream from an fd? James Kanze <james.kanze@gmail.com> - 2011-08-27 16:35 -0700
            Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-28 04:31 +0100
              Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 15:56 +1200
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-28 20:03 +0100
                Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-29 07:52 +1200
              Re: Create an istream from an fd? James Kanze <james.kanze@gmail.com> - 2011-08-29 03:54 -0700
                Re: Create an istream from an fd? Leigh Johnston <leigh@i42.co.uk> - 2011-08-29 13:55 +0100
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-29 20:12 +0100
                Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-30 07:49 +1200
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-30 04:40 +0100
                Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-30 15:51 +1200
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-31 00:03 +0100
                Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-31 11:55 +1200
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-09-02 00:50 +0100
            Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 16:04 +1200
  Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-27 02:40 +0100

csiph-web