On Tue, Mar 26, 2013 at 09:08:09PM +0100, Sven Van Caekenberghe wrote: > Maybe I am telling you things you already know, but TCP and UDP are > fundamentally different. UDP is really one-shot, try-and-hope, completely > asynchronous. In networking you generally only get a ConnectionClosed when > you actually read or write (and even then ;-).
Yes, but at least for the unix platform on close the aio/select handler is removing the socket from the registration. So there is no way to read the zero from the dead socket. :) > For your concrete question (2): just start a reading process, wrap it in a > handler and clean up. For UDP this will never happen: you will keep on > reading nothing. For TCP reading will eventually fail if the other end > disappears. Do you have an example for "handler and clean up"? I resorted to code like this for now in my 'blocking' read. [self dataAvailable] whileFalse: [[self waitForDataFor: 10] on: ConnectionTimedOut do: []]. But I have not ported my client code so I don't know if the above is working or not. This way I will get the ConnectionClosed exception at least within 10 seconds. thank you holger