OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "webrtc/base/physicalsocketserver.h" | 10 #include "webrtc/base/physicalsocketserver.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 << s_; | 187 << s_; |
188 } | 188 } |
189 return address; | 189 return address; |
190 } | 190 } |
191 | 191 |
192 int PhysicalSocket::Bind(const SocketAddress& bind_addr) { | 192 int PhysicalSocket::Bind(const SocketAddress& bind_addr) { |
193 SocketAddress copied_bind_addr = bind_addr; | 193 SocketAddress copied_bind_addr = bind_addr; |
194 // If a network binder is available, use it to bind a socket to an interface | 194 // If a network binder is available, use it to bind a socket to an interface |
195 // instead of bind(), since this is more reliable on an OS with a weak host | 195 // instead of bind(), since this is more reliable on an OS with a weak host |
196 // model. | 196 // model. |
197 if (ss_->network_binder()) { | 197 if (ss_->network_binder() && !bind_addr.IsAnyIP()) { |
198 NetworkBindingResult result = | 198 NetworkBindingResult result = |
199 ss_->network_binder()->BindSocketToNetwork(s_, bind_addr.ipaddr()); | 199 ss_->network_binder()->BindSocketToNetwork(s_, bind_addr.ipaddr()); |
200 if (result == NetworkBindingResult::SUCCESS) { | 200 if (result == NetworkBindingResult::SUCCESS) { |
201 // Since the network binder handled binding the socket to the desired | 201 // Since the network binder handled binding the socket to the desired |
202 // network interface, we don't need to (and shouldn't) include an IP in | 202 // network interface, we don't need to (and shouldn't) include an IP in |
203 // the bind() call; bind() just needs to assign a port. | 203 // the bind() call; bind() just needs to assign a port. |
204 copied_bind_addr.SetIP(GetAnyIP(copied_bind_addr.ipaddr().family())); | 204 copied_bind_addr.SetIP(GetAnyIP(copied_bind_addr.ipaddr().family())); |
205 } else if (result == NetworkBindingResult::NOT_IMPLEMENTED) { | 205 } else if (result == NetworkBindingResult::NOT_IMPLEMENTED) { |
206 LOG(LS_INFO) << "Can't bind socket to network because " | 206 LOG(LS_INFO) << "Can't bind socket to network because " |
207 "network binding is not implemented for this OS."; | 207 "network binding is not implemented for this OS."; |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 break; | 1637 break; |
1638 } | 1638 } |
1639 } | 1639 } |
1640 | 1640 |
1641 // Done | 1641 // Done |
1642 return true; | 1642 return true; |
1643 } | 1643 } |
1644 #endif // WEBRTC_WIN | 1644 #endif // WEBRTC_WIN |
1645 | 1645 |
1646 } // namespace rtc | 1646 } // namespace rtc |
OLD | NEW |