Commit 965aa3ea authored by Dave Watson's avatar Dave Watson Committed by afrind

UDP bind via port or address

Summary: Bind via port or address, similar to tcp

Test Plan: I wrote a unittest that tested v4 vs v6 binding - can't check it in because we have v6 only clusters though.  Not sure how eles to write a unittest without picking specific ports

Reviewed By: hans@fb.com

Subscribers: doug, fugalh, folly-diffs@, jsedgwick, yfeldblum, chalfant

FB internal diff: D1948938

Signature: t1:1948938:1427841721:621031320981bf366a8252a0ea1d4491b694ea24
parent d2711b8a
...@@ -89,8 +89,12 @@ class AsyncUDPServerSocketFactory : public ServerSocketFactory { ...@@ -89,8 +89,12 @@ class AsyncUDPServerSocketFactory : public ServerSocketFactory {
auto socket = std::make_shared<AsyncUDPServerSocket>( auto socket = std::make_shared<AsyncUDPServerSocket>(
EventBaseManager::get()->getEventBase()); EventBaseManager::get()->getEventBase());
socket->setReusePort(reuse); socket->setReusePort(reuse);
if (port >= 0) {
SocketAddress addressr("::1", port); SocketAddress addressr("::1", port);
socket->bind(addressr); socket->bind(addressr);
} else {
socket->bind(address);
}
socket->listen(); socket->listen();
return socket; return socket;
......
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