Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8491
| Date | 2011-10-03 08:44 -0700 |
|---|---|
| From | Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Buffered reading seems to corrupt data stream |
| References | <y4Cdne-uvN4kUBTTnZ2dnUVZ_hWdnZ2d@westnet.com.au> |
| Message-ID | <Y-adnVvGV6rhRRTTnZ2dnUVZ_hSdnZ2d@posted.palinacquisition> (permalink) |
On 10/3/11 7:58 AM, Qu0ll wrote: > [...] > The problem is that for the second or third read, the size variable is > coming back as garbage (extremely high or even negative value) and the > reading of the byte array blocks as it waits for a large amount of data > to be received or crashes with the invalid negative size even though the > previous size value and the previous bytes themselves are correct. > However, if I remove the BufferedInputStream wrapping of stream, it > works perfectly. > > Why would that be? If you don't post a concise-but-complete code example that reliably reproduces the problem (i.e. an SSCCE), there's no way to answer that question. The problem you are describing is typical of failure to treat the streams as streams, but of course that's the kind of thing that DataInputStream is supposed to address for you (and which I believe will, as long as you use it correctly…unless perhaps you're using some odd-ball Java implementation that might be more buggy than the ones you'd usually find on mainstream OSs). Another way I suppose you could observe the behavior you're describing is to be using a datagram socket instead of a stream-oriented socket. But without a proper code example, there's no way to know what you've done wrong. Pete
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Buffered reading seems to corrupt data stream "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-04 01:58 +1100
Re: Buffered reading seems to corrupt data stream "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-04 02:26 +1100
Re: Buffered reading seems to corrupt data stream Ronny Schütz <usenet.r96@gishpuppy.com> - 2011-10-03 17:54 +0200
Re: Buffered reading seems to corrupt data stream "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-04 07:07 +1100
Re: Buffered reading seems to corrupt data stream Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-03 13:18 -0700
Re: Buffered reading seems to corrupt data stream "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-04 10:54 +1100
Re: Buffered reading seems to corrupt data stream Roedy Green <see_website@mindprod.com.invalid> - 2011-10-03 11:46 -0700
Re: Buffered reading seems to corrupt data stream Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-10-03 08:44 -0700
Re: Buffered reading seems to corrupt data stream markspace <-@.> - 2011-10-03 11:33 -0700
Re: Buffered reading seems to corrupt data stream Lew <lewbloch@gmail.com> - 2011-10-04 08:48 -0700
Re: Buffered reading seems to corrupt data stream Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-10-04 09:07 -0700
Re: Buffered reading seems to corrupt data stream Lew <lewbloch@gmail.com> - 2011-10-04 12:06 -0700
csiph-web