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


Groups > comp.lang.java.programmer > #13305

Timeout Exceptions and the state of DataInputStream

From Ivan Ryan <ivan.ryan@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Timeout Exceptions and the state of DataInputStream
Date 2012-03-28 16:59 -0700
Organization http://groups.google.com
Message-ID <6b38110d-6a91-463c-ba4e-857a267705e8@b14g2000vbz.googlegroups.com> (permalink)

Show all headers | View raw


I was wondering how the DataInputStream class handles Socket timeouts.

For example, with code like the following:

someSocket.setSoTimeout(1000);

DataInputStream in = new DataInputStream(someSocket.getInputStream());

long x = in.readLong()

What would happen if the stream times out when reading the long.
Would calling in.readLong() again give the correct value.  This
assumes that the socket doesn't timeout the 2nd time.

I assume that since the DataInputStream could be reading one byte at a
time, it doesn't hold internal state.  This would mean that a few
bytes of the long could be lost?

Another option is that the stream would "unread" the bytes or
something.

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Timeout Exceptions and the state of DataInputStream Ivan Ryan <ivan.ryan@gmail.com> - 2012-03-28 16:59 -0700
  Re: Timeout Exceptions and the state of DataInputStream Knute Johnson <nospam@knutejohnson.com> - 2012-04-02 14:14 -0700
  Re: Timeout Exceptions and the state of DataInputStream Arne Vajhøj <arne@vajhoej.dk> - 2012-04-02 19:40 -0400

csiph-web