home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!airgun!airgun.wg.waii.com!bab
- From: bab@se39.wg2.waii.com (Brian Button)
- Newsgroups: comp.lang.c++
- Subject: Problem defining underflow for Tcp streambuf class
- Message-ID: <BAB.92Nov12095209@se39.wg2.waii.com>
- Date: 12 Nov 92 14:52:09 GMT
- Sender: news@airgun.wg.waii.com
- Organization: Western Geophysical Exploration Products
- Lines: 42
- Nntp-Posting-Host: se39.wg2.waii.com
-
- I'm having a problem defining the return codes from the underflow
- function for a Tcp streambuf class I've written.
-
- The problem is that underflow only returns one of two conditions,
- either a read failure or the first char successfully read. This works
- if the data being read is static, but if new data is coming in all the
- time, there seems to be a third case to be handled. It is possible
- that there is no data available to be read now, but there will be in
- the future.
-
- The problem I had arose using sbumpc(). When data was available in the
- get area, it was read and returned. When no data was already in the
- get area, underflow was called to read it, which it did, provided
- there was data available. If there wasn't, underflow was returning the
- first character available in the get area, which was put there by the
- previous read. The net effect of this was to have that character
- returned to me every time I called underflow until something else came
- available on the socket.
-
- One way to handle this is to make underflow return EOF if nothing is
- available on the socket. This would detect this case for us, and allow
- us to use clear() to recover and check the socket later with another
- call to sbumpc or whatever. The problem with this is that it would not
- let us detect the difference between a no-data failure and a
- socket-closed failure, from which there is no recovery.
-
- Does anyone out there in net.land have any suggestions about this? I
- have described it as a Tcp problem, but it really is more generic than
- that, dealing with all cases in which data is received dynamically and
- sporadically.
-
- Thanks,
-
- bab
- --
- |-----------------------|----------------------------------------------------|
- | Brian Button | email : button@wg2.waii.com |
- | Design Engineer | 71023.276@compuserve.com |
- | Western Geophysical | voice : (713)964-6221 |
- | 3600 Briarpark |----------------------------------------------------|
- | Houston, Texas 77042 | Opinions Be Mine!! |
- |-----------------------|----------------------------------------------------|
-