title: java nio: if read returns -1 does it mean client has closed connection?
body: <p>I have a question with reference to this tutorial</p>
  
  <p><a href="http://rox-xmlrpc.sourceforge.net/niotut/" rel="nofollow">http://rox-xmlrpc.sourceforge.net/niotut/</a></p>
  
  <p>In the read method of the server, if read returns -1 then does it always mean client has closed connection??</p>
  
  <p>I modified the example client to sleep for long time after sending the message I see that the selector.select() does not block and keeps selecting the channel as readable even if client is not sending anything and server reads method reads and returns -1, and thus closes the channel, but the client has not disconnected.</p>
  
  <p>I do not understand this behavior. Can some one help me understand?</p>
  
  <p>I am trying to modify the server so that the server does not disconnect with client even if client is not sending anything and so it must block at selector.select().</p>
  
  <p>thank you!</p>