| 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 IPPROTO_UDP); |
| 124 if (fd_ < 0) { | 125 if (fd_ < 0) { |
| 125 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno); | 126 return false; // failure already logged |
| 126 return false; | |
| 127 } | 127 } |
| 128 | 128 |
| 129 int get_overflow = 1; | 129 int get_overflow = 1; |
| 130 int rc = setsockopt(fd_, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow, | 130 int rc = setsockopt(fd_, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow, |
| 131 sizeof(get_overflow)); | 131 sizeof(get_overflow)); |
| 132 if (rc < 0) { | 132 if (rc < 0) { |
| 133 DLOG(WARNING) << "Socket overflow detection not supported"; | 133 DLOG(WARNING) << "Socket overflow detection not supported"; |
| 134 } else { | 134 } else { |
| 135 overflow_supported_ = true; | 135 overflow_supported_ = true; |
| 136 } | 136 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 QuicEncryptedPacket packet(buf, bytes_read, false); | 400 QuicEncryptedPacket packet(buf, bytes_read, false); |
| 401 | 401 |
| 402 IPEndPoint client_address(client_ip, client_address_.port()); | 402 IPEndPoint client_address(client_ip, client_address_.port()); |
| 403 session_->connection()->ProcessUdpPacket( | 403 session_->connection()->ProcessUdpPacket( |
| 404 client_address, server_address, packet); | 404 client_address, server_address, packet); |
| 405 return true; | 405 return true; |
| 406 } | 406 } |
| 407 | 407 |
| 408 } // namespace tools | 408 } // namespace tools |
| 409 } // namespace net | 409 } // namespace net |
| OLD | NEW |