mercredi 2 juillet 2014

Does Selector.close() closes all client sockets?


Vote count:

0




I am new to nio sockets, I have written a server using nio sockets and now I am trying to write shutdown hook to make sure a graceful exit by cleaning up resources.


My question is does Selector.close() method closes all client sockets? if not please let me know how can I access all the client sockets without having a separate list of them.


Java Doc says following for selector.close() method



Closes this selector.


If a thread is currently blocked in one of this selector's selection methods then it is interrupted as if by invoking the selector's wakeup method.


Any uncancelled keys still associated with this selector are invalidated, their channels are deregistered, and any other resources associated with this selector are released.


If this selector is already closed then invoking this method has no effect.


After a selector is closed, any further attempt to use it, except by invoking this method or the wakeup method, will cause a ClosedSelectorException to be thrown.



Above description uses word "deregistered" which gives a feeling that it does not close the sockets but just removes their mapping from selector.



asked 41 secs ago






Aucun commentaire:

Enregistrer un commentaire