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_client_socket.h" | 5 #include "net/socket/tcp_client_socket.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 private: | 96 private: |
97 scoped_refptr<TCPListenSocket> listen_sock_; | 97 scoped_refptr<TCPListenSocket> listen_sock_; |
98 scoped_refptr<TCPListenSocket> connected_sock_; | 98 scoped_refptr<TCPListenSocket> connected_sock_; |
99 bool close_server_socket_on_next_send_; | 99 bool close_server_socket_on_next_send_; |
100 }; | 100 }; |
101 | 101 |
102 void TransportClientSocketTest::SetUp() { | 102 void TransportClientSocketTest::SetUp() { |
103 ::testing::TestWithParam<ClientSocketTestTypes>::SetUp(); | 103 ::testing::TestWithParam<ClientSocketTestTypes>::SetUp(); |
104 | 104 |
105 // Find a free port to listen on | 105 // Find a free port to listen on |
106 scoped_refptr<TCPListenSocket> sock = NULL; | 106 scoped_refptr<TCPListenSocket> sock; |
107 int port; | 107 int port; |
108 // Range of ports to listen on. Shouldn't need to try many. | 108 // Range of ports to listen on. Shouldn't need to try many. |
109 const int kMinPort = 10100; | 109 const int kMinPort = 10100; |
110 const int kMaxPort = 10200; | 110 const int kMaxPort = 10200; |
111 #if defined(OS_WIN) | 111 #if defined(OS_WIN) |
112 EnsureWinsockInit(); | 112 EnsureWinsockInit(); |
113 #endif | 113 #endif |
114 for (port = kMinPort; port < kMaxPort; port++) { | 114 for (port = kMinPort; port < kMaxPort; port++) { |
115 sock = TCPListenSocket::CreateAndListen("127.0.0.1", port, this); | 115 sock = TCPListenSocket::CreateAndListen("127.0.0.1", port, this); |
116 if (sock.get()) | 116 if (sock.get()) |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 439 |
440 // It's possible the read is blocked because it's already read all the data. | 440 // It's possible the read is blocked because it's already read all the data. |
441 // Close the server socket, so there will at least be a 0-byte read. | 441 // Close the server socket, so there will at least be a 0-byte read. |
442 CloseServerSocket(); | 442 CloseServerSocket(); |
443 | 443 |
444 rv = callback.WaitForResult(); | 444 rv = callback.WaitForResult(); |
445 EXPECT_GE(rv, 0); | 445 EXPECT_GE(rv, 0); |
446 } | 446 } |
447 | 447 |
448 } // namespace net | 448 } // namespace net |
OLD | NEW |