Remy Maucherat wrote:
Filip Hanik - Dev Lists wrote:
question about this one,
since a client disconnect is signaled by a READ for the NIO connector, and the only way to find out if the client was disconnected, the InputStream.read() is supposed to return -1, how does that work with the is.available()?

For a client disconnect, you'll get an IO exception during the read, not a -1. The only situation where you'll get a -1 (that I know about) is for the end of the request body, for example if the content-length header says 10, and 10 bytes of the body have been read (so bytes may still be available on the socket, but they belong to the next request). Ideally, there would be a way to detect a disconnect in the poller so that the correct event is sent (this would avoid most IO exceptions, which is IMO much cleaner and more efficient).

I understand available() as "there's something to read, and it won't block". It also allows enforcing the rule saying that the servlet must read all the stuff that is available when it gets a read event, which doesn't hurt.
correct, but what does available() return on a client disconnect, since in NIO it's detected as a read. Are we coding it such that when a read event happens, available() always return -1

Filip

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to