// the socket is blocking, and either true or false if it's non blocking
boolean connected;
try {
connected = clientSocket.connect(remoteAddress);
} catch (IOException e) {
ConnectFuture future = new ConnectFuture();
future.cannotConnect(e);
return future;
}
ConnectFuture connectFuture = new ConnectFuture();
session.setConnectFuture(connectFuture);
if (!connected) {
// async connection, let's the connection complete in background, the selector loop will detect when the
// connection is successful