Commit e39e166b authored by Rachana Nandan's avatar Rachana Nandan Committed by Facebook Github Bot

add support to setReuseAddr in AsyncUDPServerSocket

Summary: add an api in AsyncUDPServerSocket, to enable Address reuse

Reviewed By: udippant

Differential Revision: D13306371

fbshipit-source-id: ac19a89af5694b181fcd7639a5d566684c2adc92
parent c2fd8e28
...@@ -97,6 +97,7 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback, ...@@ -97,6 +97,7 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback,
socket_ = std::make_shared<AsyncUDPSocket>(evb_); socket_ = std::make_shared<AsyncUDPSocket>(evb_);
socket_->setReusePort(reusePort_); socket_->setReusePort(reusePort_);
socket_->setReuseAddr(reuseAddr_);
socket_->bind(addy); socket_->bind(addy);
} }
...@@ -104,6 +105,10 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback, ...@@ -104,6 +105,10 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback,
reusePort_ = reusePort; reusePort_ = reusePort;
} }
void setReuseAddr(bool reuseAddr) {
reuseAddr_ = reuseAddr;
}
folly::SocketAddress address() const { folly::SocketAddress address() const {
CHECK(socket_); CHECK(socket_);
return socket_->address(); return socket_->address();
...@@ -247,6 +252,7 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback, ...@@ -247,6 +252,7 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback,
folly::IOBufQueue buf_; folly::IOBufQueue buf_;
bool reusePort_{false}; bool reusePort_{false};
bool reuseAddr_{false};
}; };
} // namespace folly } // namespace folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment