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
auto socket = std::make_shared<AsyncUDPServerSocket>(
EventBaseManager::get()->getEventBase());
socket->setReusePort(reuse);
- SocketAddress addressr("::1", port);
- socket->bind(addressr);
+ if (port >= 0) {
+ SocketAddress addressr("::1", port);
+ socket->bind(addressr);
+ } else {
+ socket->bind(address);
+ }
socket->listen();
return socket;