Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(975)

Side by Side Diff: webrtc/p2p/base/basicpacketsocketfactory.cc

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: Minor changes (comments, renaming, etc.) Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/network.h ('k') | webrtc/p2p/base/p2ptransportchannel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 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 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket( 107 AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket(
108 const SocketAddress& local_address, const SocketAddress& remote_address, 108 const SocketAddress& local_address, const SocketAddress& remote_address,
109 const ProxyInfo& proxy_info, const std::string& user_agent, int opts) { 109 const ProxyInfo& proxy_info, const std::string& user_agent, int opts) {
110 AsyncSocket* socket = 110 AsyncSocket* socket =
111 socket_factory()->CreateAsyncSocket(local_address.family(), SOCK_STREAM); 111 socket_factory()->CreateAsyncSocket(local_address.family(), SOCK_STREAM);
112 if (!socket) { 112 if (!socket) {
113 return NULL; 113 return NULL;
114 } 114 }
115 115
116 if (BindSocket(socket, local_address, 0, 0) < 0) { 116 if (BindSocket(socket, local_address, 0, 0) < 0) {
117 LOG(LS_ERROR) << "TCP bind failed with error " 117 // Allow BindSocket to fail if we're binding to the ANY address, since this
118 << socket->GetError(); 118 // is mostly redundant in the first place. The socket will be bound when we
119 delete socket; 119 // call Connect() instead.
120 return NULL; 120 if (local_address.IsAnyIP()) {
121 LOG(LS_WARNING) << "TCP bind failed with error " << socket->GetError()
122 << "; ignoring since socket is using 'any' address.";
123 } else {
124 LOG(LS_ERROR) << "TCP bind failed with error " << socket->GetError();
125 delete socket;
126 return NULL;
127 }
121 } 128 }
122 129
123 // If using a proxy, wrap the socket in a proxy socket. 130 // If using a proxy, wrap the socket in a proxy socket.
124 if (proxy_info.type == PROXY_SOCKS5) { 131 if (proxy_info.type == PROXY_SOCKS5) {
125 socket = new AsyncSocksProxySocket( 132 socket = new AsyncSocksProxySocket(
126 socket, proxy_info.address, proxy_info.username, proxy_info.password); 133 socket, proxy_info.address, proxy_info.username, proxy_info.password);
127 } else if (proxy_info.type == PROXY_HTTPS) { 134 } else if (proxy_info.type == PROXY_HTTPS) {
128 socket = 135 socket =
129 new AsyncHttpsProxySocket(socket, user_agent, proxy_info.address, 136 new AsyncHttpsProxySocket(socket, user_agent, proxy_info.address,
130 proxy_info.username, proxy_info.password); 137 proxy_info.username, proxy_info.password);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 SocketFactory* BasicPacketSocketFactory::socket_factory() { 213 SocketFactory* BasicPacketSocketFactory::socket_factory() {
207 if (thread_) { 214 if (thread_) {
208 RTC_DCHECK(thread_ == Thread::Current()); 215 RTC_DCHECK(thread_ == Thread::Current());
209 return thread_->socketserver(); 216 return thread_->socketserver();
210 } else { 217 } else {
211 return socket_factory_; 218 return socket_factory_;
212 } 219 }
213 } 220 }
214 221
215 } // namespace rtc 222 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/network.h ('k') | webrtc/p2p/base/p2ptransportchannel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698