| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/tools/quic/quic_simple_client.h" | 5 #include "net/tools/quic/quic_simple_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 bool QuicSimpleClient::CreateUDPSocket() { | 101 bool QuicSimpleClient::CreateUDPSocket() { |
| 102 scoped_ptr<UDPClientSocket> socket( | 102 scoped_ptr<UDPClientSocket> socket( |
| 103 new UDPClientSocket(DatagramSocket::DEFAULT_BIND, RandIntCallback(), | 103 new UDPClientSocket(DatagramSocket::DEFAULT_BIND, RandIntCallback(), |
| 104 &net_log_, NetLog::Source())); | 104 &net_log_, NetLog::Source())); |
| 105 | 105 |
| 106 int address_family = server_address_.GetSockAddrFamily(); | 106 int address_family = server_address_.GetSockAddrFamily(); |
| 107 if (bind_to_address_.size() != 0) { | 107 if (bind_to_address_.size() != 0) { |
| 108 client_address_ = IPEndPoint(bind_to_address_, local_port_); | 108 client_address_ = IPEndPoint(bind_to_address_, local_port_); |
| 109 } else if (address_family == AF_INET) { | 109 } else if (address_family == AF_INET) { |
| 110 client_address_ = IPEndPoint(IPAddress(0, 0, 0, 0), local_port_); | 110 client_address_ = IPEndPoint(IPAddress::IPv4AllZeros(), local_port_); |
| 111 } else { | 111 } else { |
| 112 IPAddress any6; | 112 client_address_ = IPEndPoint(IPAddress::IPv6AllZeros(), local_port_); |
| 113 CHECK(any6.AssignFromIPLiteral("::")); | |
| 114 client_address_ = IPEndPoint(any6, local_port_); | |
| 115 } | 113 } |
| 116 | 114 |
| 117 int rc = socket->Connect(server_address_); | 115 int rc = socket->Connect(server_address_); |
| 118 if (rc != OK) { | 116 if (rc != OK) { |
| 119 LOG(ERROR) << "Connect failed: " << ErrorToShortString(rc); | 117 LOG(ERROR) << "Connect failed: " << ErrorToShortString(rc); |
| 120 return false; | 118 return false; |
| 121 } | 119 } |
| 122 | 120 |
| 123 rc = socket->SetReceiveBufferSize(kDefaultSocketReceiveBuffer); | 121 rc = socket->SetReceiveBufferSize(kDefaultSocketReceiveBuffer); |
| 124 if (rc != OK) { | 122 if (rc != OK) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 session()->connection()->ProcessUdpPacket(local_address, peer_address, | 394 session()->connection()->ProcessUdpPacket(local_address, peer_address, |
| 397 packet); | 395 packet); |
| 398 if (!session()->connection()->connected()) { | 396 if (!session()->connection()->connected()) { |
| 399 return false; | 397 return false; |
| 400 } | 398 } |
| 401 | 399 |
| 402 return true; | 400 return true; |
| 403 } | 401 } |
| 404 | 402 |
| 405 } // namespace net | 403 } // namespace net |
| OLD | NEW |