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 (if not already closed), which implicitly unregisters the associated
SelectionKey
s and causes theserviceIO()
methods of other handlers waiting on the same channel to be invoked, where they will then likely throwClosedChannelException
, which in turn causes a subsequent invocation of this method. Therefore, if this instance is shared by multiple selection keys selecting on the same channel, it should be idempotent.- Parameters:
cause
- the error that occurred
-