Performance and scalability: JAVA NIO DatagramChannel
In the statement, for(Iterator i =readyKeys,iterator();i.hasNext();) SocketAddress sock = channel.receive(bytebuffer); the SocketAddress is sometimes null , even while iterating throught the readyKeys (selector.selectedKeys() Set). Could this be a bug in NIO?
The documentation states:
If this channel is in non-blocking mode and a datagram is not immediately available then this method immediately returns null.When you use NIO, your NIO-related code needs to be fairly tolerant of conditions such as this. Peace, Cameron Purdy Tangosol Coherence: The Java Data Grid
I did handle for the null condition as stated in the java documentation. But practically, the application seems to be dropping the packets, which I confirmed using the wireShark/Ethereal application This happens only in a few variants of linux like Ubuntu etc.