const folly::SocketAddress& address,
int timeout = 0,
const OptionMap &options = emptyOptionMap,
- const folly::SocketAddress& bindAddr = anyAddress)
+ const folly::SocketAddress& bindAddr = anyAddress())
noexcept override;
using AsyncSocket::connect;
// static members initializers
const AsyncSocket::OptionMap AsyncSocket::emptyOptionMap;
-const folly::SocketAddress AsyncSocket::anyAddress =
- folly::SocketAddress("0.0.0.0", 0);
const AsyncSocketException socketClosedLocallyEx(
AsyncSocketException::END_OF_FILE, "socket closed locally");
return fd;
}
+const folly::SocketAddress& AsyncSocket::anyAddress() {
+ static const folly::SocketAddress anyAddress =
+ folly::SocketAddress("0.0.0.0", 0);
+ return anyAddress;
+}
+
void AsyncSocket::setShutdownSocketSet(ShutdownSocketSet* newSS) {
if (shutdownSocketSet_ == newSS) {
return;
<< ", fd=" << fd_ << ", host=" << address.describe().c_str();
// bind the socket
- if (bindAddr != anyAddress) {
+ if (bindAddr != anyAddress()) {
int one = 1;
if (::setsockopt(fd_, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) {
doClose();
typedef std::map<OptionKey, int> OptionMap;
static const OptionMap emptyOptionMap;
- static const folly::SocketAddress anyAddress;
+ static const folly::SocketAddress& anyAddress();
/**
* Initiate a connection.
const folly::SocketAddress& address,
int timeout = 0,
const OptionMap &options = emptyOptionMap,
- const folly::SocketAddress& bindAddr = anyAddress
+ const folly::SocketAddress& bindAddr = anyAddress()
) noexcept;
void connect(ConnectCallback* callback, const std::string& ip, uint16_t port,
int timeout = 00,