| 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/udp/udp_socket_libevent.h" | 5 #include "net/udp/udp_socket_libevent.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <netdb.h> | 9 #include <netdb.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 CreateNetLogUDPDataTranferCallback( | 354 CreateNetLogUDPDataTranferCallback( |
| 355 result, bytes, | 355 result, bytes, |
| 356 is_address_valid ? &address : NULL)); | 356 is_address_valid ? &address : NULL)); |
| 357 } | 357 } |
| 358 | 358 |
| 359 base::StatsCounter read_bytes("udp.read_bytes"); | 359 base::StatsCounter read_bytes("udp.read_bytes"); |
| 360 read_bytes.Add(result); | 360 read_bytes.Add(result); |
| 361 } | 361 } |
| 362 | 362 |
| 363 int UDPSocketLibevent::CreateSocket(const IPEndPoint& address) { | 363 int UDPSocketLibevent::CreateSocket(const IPEndPoint& address) { |
| 364 socket_ = socket(address.GetFamily(), SOCK_DGRAM, 0); | 364 socket_ = socket(address.GetSockAddrFamily(), SOCK_DGRAM, 0); |
| 365 if (socket_ == kInvalidSocket) | 365 if (socket_ == kInvalidSocket) |
| 366 return MapSystemError(errno); | 366 return MapSystemError(errno); |
| 367 if (SetNonBlocking(socket_)) { | 367 if (SetNonBlocking(socket_)) { |
| 368 const int err = MapSystemError(errno); | 368 const int err = MapSystemError(errno); |
| 369 Close(); | 369 Close(); |
| 370 return err; | 370 return err; |
| 371 } | 371 } |
| 372 return OK; | 372 return OK; |
| 373 } | 373 } |
| 374 | 374 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 501 |
| 502 for (int i = 0; i < kBindRetries; ++i) { | 502 for (int i = 0; i < kBindRetries; ++i) { |
| 503 int rv = DoBind(IPEndPoint(ip, rand_int_cb_.Run(kPortStart, kPortEnd))); | 503 int rv = DoBind(IPEndPoint(ip, rand_int_cb_.Run(kPortStart, kPortEnd))); |
| 504 if (rv == OK || rv != ERR_ADDRESS_IN_USE) | 504 if (rv == OK || rv != ERR_ADDRESS_IN_USE) |
| 505 return rv; | 505 return rv; |
| 506 } | 506 } |
| 507 return DoBind(IPEndPoint(ip, 0)); | 507 return DoBind(IPEndPoint(ip, 0)); |
| 508 } | 508 } |
| 509 | 509 |
| 510 } // namespace net | 510 } // namespace net |
| OLD | NEW |