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_client.h" | 5 #include "net/tools/quic/quic_client.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <netinet/in.h> | 8 #include <netinet/in.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 QuicClient::DummyPacketWriterFactory::~DummyPacketWriterFactory() {} | 113 QuicClient::DummyPacketWriterFactory::~DummyPacketWriterFactory() {} |
114 | 114 |
115 QuicPacketWriter* QuicClient::DummyPacketWriterFactory::Create( | 115 QuicPacketWriter* QuicClient::DummyPacketWriterFactory::Create( |
116 QuicConnection* /*connection*/) const { | 116 QuicConnection* /*connection*/) const { |
117 return writer_; | 117 return writer_; |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 bool QuicClient::CreateUDPSocket() { | 121 bool QuicClient::CreateUDPSocket() { |
122 int address_family = server_address_.GetSockAddrFamily(); | 122 int address_family = server_address_.GetSockAddrFamily(); |
123 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); | 123 fd_ = QuicSocketUtils::CreateNonBlockingSocket(address_family, SOCK_DGRAM, |
124 if (fd_ < 0) { | 124 IPPROTO_UDP); |
125 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno); | 125 if (fd_ < 0) |
126 return false; | 126 return false; // failure already logged |
Ryan Hamilton
2015/03/12 03:34:38
nit: We use {}s in one-line ifs for code that's sh
dougk
2015/03/12 12:39:10
Done.
| |
127 } | |
128 | 127 |
129 int get_overflow = 1; | 128 int get_overflow = 1; |
130 int rc = setsockopt(fd_, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow, | 129 int rc = setsockopt(fd_, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow, |
131 sizeof(get_overflow)); | 130 sizeof(get_overflow)); |
132 if (rc < 0) { | 131 if (rc < 0) { |
133 DLOG(WARNING) << "Socket overflow detection not supported"; | 132 DLOG(WARNING) << "Socket overflow detection not supported"; |
134 } else { | 133 } else { |
135 overflow_supported_ = true; | 134 overflow_supported_ = true; |
136 } | 135 } |
137 | 136 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 QuicEncryptedPacket packet(buf, bytes_read, false); | 399 QuicEncryptedPacket packet(buf, bytes_read, false); |
401 | 400 |
402 IPEndPoint client_address(client_ip, client_address_.port()); | 401 IPEndPoint client_address(client_ip, client_address_.port()); |
403 session_->connection()->ProcessUdpPacket( | 402 session_->connection()->ProcessUdpPacket( |
404 client_address, server_address, packet); | 403 client_address, server_address, packet); |
405 return true; | 404 return true; |
406 } | 405 } |
407 | 406 |
408 } // namespace tools | 407 } // namespace tools |
409 } // namespace net | 408 } // namespace net |
OLD | NEW |