in wangle/bootstrap/ClientBootstrap.h [98:134]
folly::Future<Pipeline*> connect(
const folly::SocketAddress& address,
std::chrono::milliseconds timeout =
std::chrono::milliseconds(0)) override {
auto base = (group_) ? group_->getEventBase()
: folly::EventBaseManager::get()->getEventBase();
folly::Future<Pipeline*> retval((Pipeline*)nullptr);
base->runImmediatelyOrRunInEventBaseThreadAndWait([&]() {
std::shared_ptr<folly::AsyncSocket> socket;
if (this->sslContext_) {
auto sslSocket = folly::AsyncSSLSocket::newSocket(
this->sslContext_, base, this->deferSecurityNegotiation_);
if (!this->sni_.empty()) {
sslSocket->setServerName(this->sni_);
}
if (this->sslSession_) {
sslSocket->setSSLSession(this->sslSession_);
}
socket = std::move(sslSocket);
} else {
socket = folly::AsyncSocket::newSocket(base);
}
folly::Promise<Pipeline*> promise;
retval = promise.getFuture();
DCHECK_LE(timeout.count(), std::numeric_limits<int>::max());
socket->connect(
new ConnectCallback(
std::move(promise),
this,
socket,
std::move(this->sslSessionEstablishedCallback_)),
address,
folly::to_narrow(timeout.count()),
BaseClientBootstrap<Pipeline>::getSocketOptions(address.getFamily()));
});
return retval;
}