check connection readyness in SocketChannel.finishConnect if necessary

This commit is contained in:
Joel Dice 2011-01-11 18:39:48 -07:00
parent eb3a9f010b
commit 39018c20e0

@ -67,11 +67,16 @@ public class SocketChannel extends SelectableChannel
public boolean finishConnect() throws IOException {
if (! connected) {
while (blocking && ! readyToConnect) {
while (! readyToConnect) {
Selector selector = Selector.open();
SelectionKey key = register(selector, SelectionKey.OP_CONNECT, null);
selector.select();
if (blocking) {
selector.select();
} else {
selector.selectNow();
break;
}
}
natFinishConnect(socket);