In my last post we created a UDP client using Apache MINA. Lets turn the table and implement the Server side. Let’s see how using Apache MINA reduces the effort to create a UDP Server.

Steps to create a UDP Server using java.net API’s

Create a Socket and listen for incoming connection Process each packet in a separate thread 🙂 (I hate this, unfortunately need this to have high processing rate) Parse and process the request and optionally send response (Lets omit this to keep things simple)

Lets see how to achieve the same using Apache MINA

Create a NioDatagramAcceptor Add an IoHandler Bind and make application ready to receive

That’s it 🙂

Before we dive into the code, lets see some assumption made to run this