This question regards Java\'s NIO on Android (2.2, though I can build for higher APIs if necessary): After performing a SocketChannel connect() to a destination IP address, I re
You're doing it wrong.
While the connection is pending, the channel must only be registered for OP_CONNECT.
When OP_CONNECT fires, you must call finishConnect(), and then proceed as follows:
If it returns true, you must then deregister OP_CONNECT, and you may then register OP_READ or OP_WRITE.
If it returns false, do nothing: the connection is still pending.
If it throws an exception, the connect has failed and you must close the channel.