Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to determine that an input stream (or a socket) is breaken?
- From: prasanna@xxxxxxxxxxxxxxxx (VijayaBalaji Prasanna)
- Subject: How to determine that an input stream (or a socket) is breaken?
- Date: Thu, 30 Sep 1999 14:13:13 -0400
In general, if the readLine() method in BufferReader returns a null, then it actually means that there is no more data to be read on the socket or the stream. Typically, it means that the end of file has been reached. If the socket or stream is broken, an IOException will be thrown. Prasanna. Xizhen Wang wrote: > Hi! all, > > In java, how to determine that an input stream (or a socket) is broken? > I use a BufferedReader (i.e. in) to read from this stream, and when > in.readline() == null, I understand the connection is broken. Does that > make sense on NT and Solaris? Or is there a better way to do that? > > Is there a sample code or a way to do this? > 1. Keep the socket connection open. > 2. read from the input stream whenever there is new data coming in. > (3. the reading thread is blocked when there is not no new data. or at > least does not occupy big CPU time for looping) > > Can anyone give me a hand? Help is needed urgently. > > Thank you! > Xizhen > > --- > To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx > To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx --- To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
- References:
- How to determine that an input stream (or a socket) is breaken?
- From: Xizhen Wang
- How to determine that an input stream (or a socket) is breaken?
- Prev by Date: Awt exceptions
- Next by Date: concatenating streams
- Previous by thread: How to determine that an input stream (or a socket) is breaken?
- Next by thread: Portuguese messages on advanced-java
- Index(es):