Closed rschildmeijer closed 13 years ago
After some experimenting I just realized that the AsynchronousSocket (in it's current state) do support server operations. What is "wrong" in the example above is that the AS is initialized with a ServerSocketChannel (server variable)...if the AS instead is given the return value from server.accept (which is ok to invoke if we have got a handleAccept callback from an IOHandler that is registered in an IOLoop), things work as expected. I do admit that the javadoc (for AS) could be better. But that is probably better to solve in a seperate issue
Following throws IllegalArgumentException: ServerSocketChannel server = ServerSocketChannel.open(); server.configureBlocking(false); server.socket().bind(new InetSocketAddress(9090)); AsynchronousSocket socket = new AsynchronousSocket(server); // use socket IOLoop.INSTANCE.start();
Currently the AS only support SocketChannel (connect). (i.e no support for eg. ServerSocketChannel (bind)).
I did a quick test and added:
else if (channel instanceof ServerSocketChannel) { interestOps = SelectionKey.OP_ACCEPT; } to the two parameters version of the AS ctor and that is probably a good start.