| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/socket/tcp_socket.h" | 5 #include "net/socket/tcp_socket.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 socket_.Bind(address) != OK || | 49 socket_.Bind(address) != OK || |
| 50 socket_.Listen(kListenBacklog) != OK) { | 50 socket_.Listen(kListenBacklog) != OK) { |
| 51 LOG(ERROR) << "Failed to listen on ::1 - probably because IPv6 is " | 51 LOG(ERROR) << "Failed to listen on ::1 - probably because IPv6 is " |
| 52 "disabled. Skipping the test"; | 52 "disabled. Skipping the test"; |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 ASSERT_EQ(OK, socket_.GetLocalAddress(&local_address_)); | 55 ASSERT_EQ(OK, socket_.GetLocalAddress(&local_address_)); |
| 56 *success = true; | 56 *success = true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ParseAddress(const std::string& ip_str, int port, IPEndPoint* address) { | 59 void ParseAddress(const std::string& ip_str, |
| 60 uint16 port, |
| 61 IPEndPoint* address) { |
| 60 IPAddressNumber ip_number; | 62 IPAddressNumber ip_number; |
| 61 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); | 63 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); |
| 62 if (!rv) | 64 if (!rv) |
| 63 return; | 65 return; |
| 64 *address = IPEndPoint(ip_number, port); | 66 *address = IPEndPoint(ip_number, port); |
| 65 } | 67 } |
| 66 | 68 |
| 67 void TestAcceptAsync() { | 69 void TestAcceptAsync() { |
| 68 TestCompletionCallback accept_callback; | 70 TestCompletionCallback accept_callback; |
| 69 scoped_ptr<TCPSocket> accepted_socket; | 71 scoped_ptr<TCPSocket> accepted_socket; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 memmove(&buffer[bytes_read], read_buffer->data(), read_result); | 279 memmove(&buffer[bytes_read], read_buffer->data(), read_result); |
| 278 bytes_read += read_result; | 280 bytes_read += read_result; |
| 279 } | 281 } |
| 280 | 282 |
| 281 std::string received_message(buffer.begin(), buffer.end()); | 283 std::string received_message(buffer.begin(), buffer.end()); |
| 282 ASSERT_EQ(message, received_message); | 284 ASSERT_EQ(message, received_message); |
| 283 } | 285 } |
| 284 | 286 |
| 285 } // namespace | 287 } // namespace |
| 286 } // namespace net | 288 } // namespace net |
| OLD | NEW |