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/socket/tcp_server_socket.h" | 5 #include "net/socket/tcp_server_socket.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 ParseAddress("::1", 0, &address); | 43 ParseAddress("::1", 0, &address); |
44 if (socket_.Listen(address, kListenBacklog) != 0) { | 44 if (socket_.Listen(address, kListenBacklog) != 0) { |
45 LOG(ERROR) << "Failed to listen on ::1 - probably because IPv6 is " | 45 LOG(ERROR) << "Failed to listen on ::1 - probably because IPv6 is " |
46 "disabled. Skipping the test"; | 46 "disabled. Skipping the test"; |
47 return; | 47 return; |
48 } | 48 } |
49 ASSERT_EQ(OK, socket_.GetLocalAddress(&local_address_)); | 49 ASSERT_EQ(OK, socket_.GetLocalAddress(&local_address_)); |
50 *success = true; | 50 *success = true; |
51 } | 51 } |
52 | 52 |
53 void ParseAddress(std::string ip_str, int port, IPEndPoint* address) { | 53 void ParseAddress(std::string ip_str, uint16 port, IPEndPoint* address) { |
54 IPAddressNumber ip_number; | 54 IPAddressNumber ip_number; |
55 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); | 55 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); |
56 if (!rv) | 56 if (!rv) |
57 return; | 57 return; |
58 *address = IPEndPoint(ip_number, port); | 58 *address = IPEndPoint(ip_number, port); |
59 } | 59 } |
60 | 60 |
61 static IPEndPoint GetPeerAddress(StreamSocket* socket) { | 61 static IPEndPoint GetPeerAddress(StreamSocket* socket) { |
62 IPEndPoint address; | 62 IPEndPoint address; |
63 EXPECT_EQ(OK, socket->GetPeerAddress(&address)); | 63 EXPECT_EQ(OK, socket->GetPeerAddress(&address)); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 bytes_read += read_result; | 242 bytes_read += read_result; |
243 } | 243 } |
244 | 244 |
245 std::string received_message(buffer.begin(), buffer.end()); | 245 std::string received_message(buffer.begin(), buffer.end()); |
246 ASSERT_EQ(message, received_message); | 246 ASSERT_EQ(message, received_message); |
247 } | 247 } |
248 | 248 |
249 } // namespace | 249 } // namespace |
250 | 250 |
251 } // namespace net | 251 } // namespace net |
OLD | NEW |