Hi,

In preparation for HTTPx in the future, I was looking at how to start
adding UDP, and:
- NIO2 and APR don't have datagram support, the first one is hopeless and
the second one is legacy.
- It would be better to avoid duplicating the whole NIO connector, but
rather add a datagram mode to it.
- I think the "best" way is to change NioChannel.sc to be a
SelectableChannel, and then use casts (to ByteChannel, etc). The class
hierarchy between SocketChannel and DatagramChannel is otherwise rather
annoying.
- Many of the methods are identical between SocketChannel and
DatagramChannel (socket properties, address access, etc etc), but
unfortunately they are only on the concrete class. Since I don't think
reflection should be used, this means some amount of duplication and
casting.
- Along the way, I noticed NioChannel.close does sc.socket.close() then
sc.close(). Normally that's useless. I'm pretty sure this was done to
workaround old bugs that are most likely fixed now (I found references
online for Java 4, 5 and 6, but nothing since then). So this could be
simplified to just close the SelectableChannel.

Any ideas ?

Rémy

Reply via email to