* does not succeed within this period,
* callback->connectError() will be invoked.
*/
- virtual void connect(ConnectCallback* callback,
- const folly::SocketAddress& address,
- int timeout = 0,
- const OptionMap &options = emptyOptionMap,
- const folly::SocketAddress& bindAddr = anyAddress()
- ) noexcept;
- void connect(ConnectCallback* callback, const std::string& ip, uint16_t port,
- int timeout = 00,
- const OptionMap &options = emptyOptionMap) noexcept;
+ virtual void connect(
+ ConnectCallback* callback,
+ const folly::SocketAddress& address,
+ int timeout = 0,
+ const OptionMap& options = emptyOptionMap,
+ const folly::SocketAddress& bindAddr = anyAddress()) noexcept;
+
+ void connect(
+ ConnectCallback* callback,
+ const std::string& ip,
+ uint16_t port,
+ int timeout = 0,
+ const OptionMap& options = emptyOptionMap) noexcept;
/**
* If a connect request is in-flight, cancels it and closes the socket
return connectEndTime_ - connectStartTime_;
}
+ std::chrono::milliseconds getConnectTimeout() const {
+ return connectTimeout_;
+ }
+
// Methods controlling socket options
/**
std::chrono::steady_clock::time_point connectStartTime_;
std::chrono::steady_clock::time_point connectEndTime_;
+ std::chrono::milliseconds connectTimeout_{0};
+
BufferCallback* bufferCallback_{nullptr};
};
#ifdef _MSC_VER
CHECK_EQ(cb.state, STATE_SUCCEEDED);
EXPECT_LE(0, socket->getConnectTime().count());
+ EXPECT_EQ(socket->getConnectTimeout(), std::chrono::milliseconds(30));
}
/**
CHECK_EQ(cb.state, STATE_FAILED);
CHECK_EQ(cb.exception.getType(), AsyncSocketException::NOT_OPEN);
EXPECT_LE(0, socket->getConnectTime().count());
+ EXPECT_EQ(socket->getConnectTimeout(), std::chrono::milliseconds(30));
}
/**
socket->getPeerAddress(&peer);
CHECK_EQ(peer, addr);
EXPECT_LE(0, socket->getConnectTime().count());
+ EXPECT_EQ(socket->getConnectTimeout(), std::chrono::milliseconds(1));
}
/**
ASSERT_TRUE(socket->isClosedBySelf());
ASSERT_FALSE(socket->isClosedByPeer());
+ EXPECT_EQ(socket->getConnectTimeout(), std::chrono::milliseconds(30));
}
/**