Re: Detecting clsoed socket on OutputStream.Write



Knute Johnson wrote:

That's why the read throws an exception immediately then, the outgoing data is locally buffered? How long will the local data be buffered? Does not the flush() cause it to go now?

All that flush() does is is get it out of the JVM into the socket send buffer. The data can only go from there onto the wire if there is room in the receiver's receive buffer, and if the receiver is slower than the sender eventually the room will run out. Also, data is only deleted from the sender's send buffer once it has bene acknowledged by the receiver. So if the receiver completely disappears eventually your send buffer will fill up and eventually your TCP will time out the write attemps and reset the connection. Your *next* read or write will then discover this and get a SocketException.
.



Relevant Pages

  • Re: Flushing a socket
    ... > I need to flush an socket after a send. ... So i knew only a little bit about linux. ... sendis not guaranteed to send a given buffer of data all at once. ...
    (comp.os.linux.development.apps)
  • Re: Making sure you receive it all
    ... on the TCP socket level in your app you simply ... Let's say you have a buffer of 4K (the size must be chosen ... packet size and it decodes it from network byte order. ... at the receiver the size in network byte order... ...
    (microsoft.public.win32.programmer.networks)
  • Re: "secure" file flag?
    ... you really need to flush the on-device cache on each ... > pass to make sure the bit patterns get written to the platter in proper ... A simple algorithm could just mark each buffer with a special ... read all file blocks into buffers that are marked dirty and get the ...
    (freebsd-hackers)
  • Re: Response.Flush: Differences between IIS 6.0 and 5.0?
    ... since IIS 6.0 is now on top of http.sys. ... smaller buffer and so on, each flush cause the packet to send.... ... > Server: Microsoft-IIS/5.0 ...
    (microsoft.public.inetserver.iis)
  • Re: Can anyone explain why this is happening?
    ... Is it possible that your writes do not include a local buffer flush ... written file (to guarantee that newly written data have been flushed to ... before it reads from a new file (which also flushes all buffered written ...
    (comp.parallel.mpi)