I\'m implementing a Discover process that:
I did get some errors but the socket get closed properly... which is oki for my needs
No, in case you've got errors your channel is NOT closed properly.
You have to do close in the finally clause of your try block.
Selector selector = Selector.open();
try
{
DatagramChannel channel = DatagramChannel.open();
try
{
channel.configureBlocking(true);
channel.socket().bind(
new InetSocketAddress(InetAddress.getLocalHost(), 9005)
);
SelectionKey clientKey = channel.register(selector, SelectionKey.OP_READ);
clientKey.cancel();
}
finally
{
channel.close();
}
}
finally
{
selector.close( )
}