Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19430
| From | Steven Simpson <ss@domain.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: detecting Socket disconnect |
| Date | 2012-10-18 09:31 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <vbr4l9-nu4.ln1@s.simpson148.btinternet.com> (permalink) |
| References | <c46d29c6-f804-43da-b748-ef50c3a8bdfa@googlegroups.com> <asnu3x7eu41t.5lxnh3cm080e$.dlg@40tude.net> |
On 17/10/12 21:59, Peter Duniho wrote: > On Wed, 17 Oct 2012 13:12:13 -0700 (PDT), bob smith wrote: >> I have a java.net.Socket that I only write to, and I can't figure out how to tell if it's disconnected. > The normal way to detect a disconnect is to read from the socket and get a > return value of 0 bytes for the count of bytes. This is the case in C, where functions like recv() use -1 to signal an error and 0 for EOF. However, in Java, InputStream (such as you get from a Socket) returns -1 to signal EOF. <http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html> -- ss at comp dot lancs dot ac dot uk
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
detecting Socket disconnect bob smith <bob@coolfone.comze.com> - 2012-10-17 13:12 -0700
Re: detecting Socket disconnect Arne Vajhoej <arne@vajhoej.dk> - 2012-10-17 16:45 -0400
Re: detecting Socket disconnect Lew <lewbloch@gmail.com> - 2012-10-17 13:47 -0700
Re: detecting Socket disconnect Arne Vajhoej <arne@vajhoej.dk> - 2012-10-17 17:19 -0400
Re: detecting Socket disconnect Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-17 13:59 -0700
Re: detecting Socket disconnect Arne Vajhoej <arne@vajhoej.dk> - 2012-10-17 17:24 -0400
Re: detecting Socket disconnect Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-17 14:42 -0700
Re: detecting Socket disconnect Steven Simpson <ss@domain.invalid> - 2012-10-18 09:31 +0100
Re: detecting Socket disconnect Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-18 07:09 -0700
Re: detecting Socket disconnect Martin Gregorie <martin@address-in-sig.invalid> - 2012-10-17 21:14 +0000
Re: detecting Socket disconnect Roedy Green <see_website@mindprod.com.invalid> - 2012-10-17 15:52 -0700
csiph-web