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

Unified Diff: net/tools/quic/quic_client.cc

Issue 1752823002: n/a (QUIC toy client/server changes) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@115400573
Patch Set: Revert to Patch Set 1 Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_client.h ('k') | net/tools/quic/quic_client_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_client.cc
diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc
index 6a4c3127c7c7ddb3de808dbe4f9b0c9c510e9f10..f0aee5bc9aefe0406ed4d61873e0c45178d0d8d4 100644
--- a/net/tools/quic/quic_client.cc
+++ b/net/tools/quic/quic_client.cc
@@ -109,7 +109,7 @@ bool QuicClient::Initialize() {
epoll_server_->set_timeout_in_us(50 * 1000);
- if (!CreateUDPSocket()) {
+ if (!CreateUDPSocketAndBind()) {
return false;
}
@@ -129,41 +129,17 @@ QuicClient::QuicDataToResend::~QuicDataToResend() {
}
}
-bool QuicClient::CreateUDPSocket() {
- int address_family = server_address_.GetSockAddrFamily();
- int fd = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP);
+bool QuicClient::CreateUDPSocketAndBind() {
+ int fd =
+ QuicSocketUtils::CreateUDPSocket(server_address_, &overflow_supported_);
if (fd < 0) {
- LOG(ERROR) << "CreateSocket() failed: " << strerror(errno);
- return false;
- }
-
- int get_overflow = 1;
- int rc = setsockopt(fd, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow,
- sizeof(get_overflow));
- if (rc < 0) {
- DLOG(WARNING) << "Socket overflow detection not supported";
- } else {
- overflow_supported_ = true;
- }
-
- if (!QuicSocketUtils::SetReceiveBufferSize(fd, kDefaultSocketReceiveBuffer)) {
- return false;
- }
-
- if (!QuicSocketUtils::SetSendBufferSize(fd, kDefaultSocketReceiveBuffer)) {
- return false;
- }
-
- rc = QuicSocketUtils::SetGetAddressInfo(fd, address_family);
- if (rc < 0) {
- LOG(ERROR) << "IP detection not supported" << strerror(errno);
return false;
}
IPEndPoint client_address;
if (bind_to_address_.size() != 0) {
client_address = IPEndPoint(bind_to_address_, local_port_);
- } else if (address_family == AF_INET) {
+ } else if (server_address_.GetSockAddrFamily() == AF_INET) {
client_address = IPEndPoint(IPAddress(0, 0, 0, 0), local_port_);
} else {
IPAddress any6;
@@ -175,7 +151,8 @@ bool QuicClient::CreateUDPSocket() {
socklen_t raw_addr_len = sizeof(raw_addr);
CHECK(client_address.ToSockAddr(reinterpret_cast<sockaddr*>(&raw_addr),
&raw_addr_len));
- rc = bind(fd, reinterpret_cast<const sockaddr*>(&raw_addr), sizeof(raw_addr));
+ int rc =
+ bind(fd, reinterpret_cast<const sockaddr*>(&raw_addr), sizeof(raw_addr));
if (rc < 0) {
LOG(ERROR) << "Bind failed: " << strerror(errno);
return false;
@@ -390,7 +367,7 @@ bool QuicClient::MigrateSocket(const IPAddress& new_host) {
CleanUpUDPSocket(GetLatestFD());
bind_to_address_ = new_host;
- if (!CreateUDPSocket()) {
+ if (!CreateUDPSocketAndBind()) {
return false;
}
« no previous file with comments | « net/tools/quic/quic_client.h ('k') | net/tools/quic/quic_client_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698