Commit 023744f6 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

Allow AsyncServerSocket::bind to be called for multiple addrs (same as for port bind)

Summary: Allow AsyncServerSocket::bind to be called for multiple addrs (same as for port bind)

Reviewed By: yfeldblum

Differential Revision: D18046496

fbshipit-source-id: efde498fbaa02357d7c66905b8c1e5e839062076
parent 8f2abf77
......@@ -374,17 +374,15 @@ void AsyncServerSocket::bind(
if (ipAddresses.empty()) {
throw std::invalid_argument("No ip addresses were provided");
}
if (!sockets_.empty()) {
throw std::invalid_argument(
"Cannot call bind on a AsyncServerSocket "
"that already has a socket.");
if (eventBase_) {
eventBase_->dcheckIsInEventBaseThread();
}
for (const IPAddress& ipAddress : ipAddresses) {
SocketAddress address(ipAddress.toFullyQualified(), port);
auto fd = createSocket(address.getFamily());
bindSocket(fd, address, false);
bindSocket(fd, address, !sockets_.empty());
}
if (sockets_.size() == 0) {
throw std::runtime_error(
......
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