public void ready()

in core/src/main/java/org/apache/mina/transport/nio/NioUdpServer.java [222:265]


    public void ready(final boolean accept, boolean connect, final boolean read, final ByteBuffer readBuffer,
            final boolean write) {
        // Process the reads first
        try {
            // System.err.println("remaining : " + readBuffer.remaining());
            final SocketAddress source = datagramChannel.receive(readBuffer);
            NioUdpSession session = null;

            // let's find the corresponding session
            if (source != null) {
                session = sessions.get(source);

                if (session == null) {
                    session = createSession(source, datagramChannel);
                }
                if (read) {
                    if (IS_DEBUG) {
                        LOG.debug("readable datagram for UDP service : {}", this);
                    }

                    readBuffer.flip();

                    if (IS_DEBUG) {
                        LOG.debug("read {} bytes form {}", readBuffer.remaining(), source);
                    }

                    session.receivedDatagram(readBuffer);

                }

                // Now, process the writes
                if (write) {
                    session.processWrite(readSelectorLoop);
                }
            } else {
                if (IS_DEBUG) {
                    LOG.debug("Do data to read");
                }
            }

        } catch (final IOException ex) {
            LOG.error("IOException while reading the socket", ex);
        }
    }