I am trying to implement UDP using NIO in some way… I tried it the same way I am with TCP;
case UDPServer:
channel = DatagramChannel.open();
((DatagramChannel)channel).socket().bind(new InetSocketAddress("localhost", port));
clients = new Vector();
break;
and then to register:
channel.register(selector, SelectionKey.OP_ACCEPT);
I get an exception at that last line:
java.lang.IllegalArgumentException
at java.nio.channels.spi.AbstractSelectableChannel.register(AbstractSelectableChannel.java:170)
at java.nio.channels.SelectableChannel.register(SelectableChannel.java:254)
at SpeedConn.SpeedChannel.register(SpeedChannel.java:209)
at SpeedConn.SpeedConn.run(SpeedConn.java:43)
Anyone got a hint?