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

Side by Side Diff: net/tools/quic/quic_socket_utils.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, 9 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 | « net/tools/quic/quic_socket_utils.h ('k') | net/tools/quic/test_tools/quic_client_peer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_socket_utils.h" 5 #include "net/tools/quic/quic_socket_utils.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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 int rc = sendmsg(fd, &hdr, 0); 216 int rc = sendmsg(fd, &hdr, 0);
217 if (rc >= 0) { 217 if (rc >= 0) {
218 return WriteResult(WRITE_STATUS_OK, rc); 218 return WriteResult(WRITE_STATUS_OK, rc);
219 } 219 }
220 return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK) 220 return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK)
221 ? WRITE_STATUS_BLOCKED 221 ? WRITE_STATUS_BLOCKED
222 : WRITE_STATUS_ERROR, 222 : WRITE_STATUS_ERROR,
223 errno); 223 errno);
224 } 224 }
225 225
226 // static
227 int QuicSocketUtils::CreateUDPSocket(const IPEndPoint& address,
228 bool* overflow_supported) {
229 int address_family = address.GetSockAddrFamily();
230 int fd = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP);
231 if (fd < 0) {
232 LOG(ERROR) << "socket() failed: " << strerror(errno);
233 return -1;
234 }
235
236 int get_overflow = 1;
237 int rc = setsockopt(fd, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow,
238 sizeof(get_overflow));
239 if (rc < 0) {
240 DLOG(WARNING) << "Socket overflow detection not supported";
241 } else {
242 *overflow_supported = true;
243 }
244
245 if (!QuicSocketUtils::SetReceiveBufferSize(fd, kDefaultSocketReceiveBuffer)) {
246 return -1;
247 }
248
249 if (!QuicSocketUtils::SetSendBufferSize(fd, kDefaultSocketReceiveBuffer)) {
250 return -1;
251 }
252
253 rc = QuicSocketUtils::SetGetAddressInfo(fd, address_family);
254 if (rc < 0) {
255 LOG(ERROR) << "IP detection not supported" << strerror(errno);
256 return -1;
257 }
258 return fd;
259 }
260
226 } // namespace net 261 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_socket_utils.h ('k') | net/tools/quic/test_tools/quic_client_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698