Re: Detecting clsoed socket on OutputStream.Write



EJP wrote:
Knute Johnson wrote:
I don't know what causes the expected behavior to fail.

What causes this 'expected behaviour' to 'fail' is TCP asynchronous writing and buffering. If the write to the socket just goes into your local send buffer and the remote close hasn't already been detected, your write will succeed. It's only when you write *after* the remote close has been detected that you can get an IOException, and this in turn can only happen if there was data still pending to be written when the remote closure occurred.

In practice this means doing a number of writes to provoke the IOException: you can't rely on a single write doing it, i.e. you can't rely on the *next* write getting an IOException.

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?

Thanks,

--

Knute Johnson
email s/nospam/knute/
.



Relevant Pages

  • Re: anybody out there who uses Visual Foxpro on Progress (V9) data??
    ... Have you set a buffering level 3 or 5 for the view. ... With 3, row buffering, the update occurs whenb you move off the row in the ... the connection and driver are working as expected and the problem would more ... >> It is a remote view on a single table. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Remote view / cursor oddity
    ... I don't see what buffering has to do with my problem. ... If nothing is open in the data session, and 'track' is a remote view ... USE track IN 0 ALIAS track_curs ... instead of opening a 'track' cursor and inserting into that. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Remote view / cursor oddity
    ... If you're using a remote view, there is an implied buffering mode in effect. ... If you move the record pointer in the view, any changes in that record in ... > * since when it completes there is no alias 'track' open. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: remote view and stored procedures
    ... Not remote views, but buffering could still be useful for form level stuff ... that catches buffer changes before navigation (i.e., ...
    (microsoft.public.fox.programmer.exchange)
  • Lost data on socket - Can we start over politely?
    ... input at the server. ... I've switched to using only buffered reads and writes on the socket fd's, ... It's not buffering ... sub get_packet { ...
    (comp.lang.perl.misc)