Re: Winsock and IOStreams
From: Eugene Gershnik (gershnik_at_hotmail.com)
Date: 09/03/04
- Next message: Callum Winter: "Re: Log Out Issues"
- Previous message: Eugene Gershnik: "Re: Large performance hit when opening shared network file."
- In reply to: yerl_at_twenty.net: "Winsock and IOStreams"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 3 Sep 2004 01:58:38 -0700
yerl@twenty.net wrote:
> No doubt this will sound n(oo|ew)bish but here goes.
>
> First,
> There are two methods of snagging a 'line' from a stream.
There are many things called stream and many ways to read from them. If you
need an advice about C++ iostreams a better place to ask is
comp.lang.c++.moderated or one of the vc newsgroups.
One small advice. If (as the title of your post suggests) you try to use
iostreams to read from a socket then I would strongly recommend to avoid
doing so. Read network data into a memory buffer and then if you wish attach
a C++ streambuf to it.
The rest is an attempt to answer your questions.
> One is the
> std function "getline" and the other is the "getline" method of the
> stream itself. Silly the stream only takes a char_type buffer when the
> 'std::getline()' takes a bonafide string reference! I prefer the one
> that takes the basic_string ref. Here's the dilema with this
> approach, I don't know how to test for EOF. :(
Check for failbit on the stream.
> Second,
> This is the silliest thing. Since we are dealing with Windows or at
> least I am I'd like to know a C++/Win programmer accepted way of
> removing the trailing '\r' from the result of one of the getline
> formats. I don't want to assume the '\r' is there so I'd appreciate
> some options.
Make sure your stream is in "text" rather than "binary" mode. In text mode
the '\r' will disappear.
> I'm still working through "Standard C++ IOStreams and Locales" so
> perhaps the answer is there.
Perhaps. In absence of any other references this is automatically the best
book on the topic.
-- Eugene
- Next message: Callum Winter: "Re: Log Out Issues"
- Previous message: Eugene Gershnik: "Re: Large performance hit when opening shared network file."
- In reply to: yerl_at_twenty.net: "Winsock and IOStreams"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|