Package org.dellroad.stuff.net
Interface SelectorSupport.IOHandler
- All Known Implementing Classes:
ChannelConnection
,TCPConnection
- Enclosing class:
- SelectorSupport
public static interface SelectorSupport.IOHandler
Callback interface used by
SelectorSupport
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked when an exception is thrown byserviceIO()
.void
serviceIO
(SelectionKey key) Handle ready I/O.
-
Method Details
-
serviceIO
Handle ready I/O.- Parameters:
key
- selection key- Throws:
IOException
- if an I/O error occurs; this will result inclose()
being invoked
-
close
Invoked when an exception is thrown byserviceIO()
.This usually indicates the channel has been (or should be) closed. In any case, it allows for this handler to perform any required cleanup.
Typically this method will close the associated channel, which implicitly unregisters the associated
SelectionKey
s. This also causes theserviceIO()
methods of other handlers waiting on the same channel to be invoked due to the ready I/O, where they will then likely throwClosedChannelException
, causing another invocation of this method. Therefore, this method should be idempotent.- Parameters:
cause
- the error that occurred
-