OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include "v8.h" | 3 #include "v8.h" |
4 #include "platform.h" | 4 #include "platform.h" |
5 #include "cctest.h" | 5 #include "cctest.h" |
6 | 6 |
7 | 7 |
8 using namespace ::v8::internal; | 8 using namespace ::v8::internal; |
9 | 9 |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 Socket* client_; // Single client connection used by the test. | 35 Socket* client_; // Single client connection used by the test. |
36 Semaphore* listening_; // Signalled when the server socket is in listen mode. | 36 Semaphore* listening_; // Signalled when the server socket is in listen mode. |
37 }; | 37 }; |
38 | 38 |
39 | 39 |
40 void SocketListenerThread::Run() { | 40 void SocketListenerThread::Run() { |
41 bool ok; | 41 bool ok; |
42 | 42 |
43 // Create the server socket and bind it to the requested port. | 43 // Create the server socket and bind it to the requested port. |
44 server_ = OS::CreateSocket(); | 44 server_ = OS::CreateSocket(); |
| 45 server_->SetReuseAddress(true); |
45 CHECK(server_ != NULL); | 46 CHECK(server_ != NULL); |
46 ok = server_->Bind(port_); | 47 ok = server_->Bind(port_); |
47 CHECK(ok); | 48 CHECK(ok); |
48 | 49 |
49 // Listen for new connections. | 50 // Listen for new connections. |
50 ok = server_->Listen(1); | 51 ok = server_->Listen(1); |
51 CHECK(ok); | 52 CHECK(ok); |
52 listening_->Signal(); | 53 listening_->Signal(); |
53 | 54 |
54 // Accept a connection. | 55 // Accept a connection. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 153 } |
153 | 154 |
154 | 155 |
155 TEST(HToNNToH) { | 156 TEST(HToNNToH) { |
156 uint16_t x = 1234; | 157 uint16_t x = 1234; |
157 CHECK_EQ(x, Socket::NToH(Socket::HToN(x))); | 158 CHECK_EQ(x, Socket::NToH(Socket::HToN(x))); |
158 | 159 |
159 uint32_t y = 12345678; | 160 uint32_t y = 12345678; |
160 CHECK(y == Socket::NToH(Socket::HToN(y))); | 161 CHECK(y == Socket::NToH(Socket::HToN(y))); |
161 } | 162 } |
OLD | NEW |