in core/src/main/java/org/apache/mina/transport/nio/NioUdpSession.java [263:309]
public void ready(boolean accept, boolean connect, boolean read, ByteBuffer readBuffer, boolean write) {
if (IS_DEBUG) {
LOG.debug("session {} ready for accept={}, connect={}, read={}, write={}", new Object[] { this, accept,
connect, read, write });
}
if (read) {
if (IS_DEBUG) {
LOG.debug("readable datagram for UDP service : {}", this);
}
// Read everything we can up to the buffer size
try {
readBuffer.clear();
((DatagramChannel) channel).receive(readBuffer);
readBuffer.flip();
int readbytes = readBuffer.remaining();
if (IS_DEBUG) {
LOG.debug("read {} bytes", readbytes);
}
if (readbytes <= 0) {
// session closed by the remote peer
if (IS_DEBUG) {
LOG.debug("session closed by the remote peer");
}
close(true);
} else {
receivedDatagram(readBuffer);
}
} catch (IOException e) {
processException(e);
}
}
if (write) {
processWrite(selectorLoop);
}
if (accept) {
throw new IllegalStateException("accept event should never occur on NioUdpSession");
}
}