| 15 | namespace SC |
| 16 | { |
| 17 | static Result createServer(AsyncEventLoop& eventLoop, SocketDescriptor& serverSocket, SocketIPAddress& address) |
| 18 | { |
| 19 | constexpr uint16_t firstPort = 39091; |
| 20 | constexpr uint16_t numPorts = 64; |
| 21 | |
| 22 | Result lastError = Result::Error("Could not bind AwaitEcho socket"); |
| 23 | for (uint16_t offset = 0; offset < numPorts; ++offset) |
| 24 | { |
| 25 | const uint16_t port = static_cast<uint16_t>(firstPort + offset); |
| 26 | SC_TRY(address.fromAddressPort("127.0.0.1", port)); |
| 27 | |
| 28 | SocketDescriptor candidate; |
| 29 | SC_TRY(eventLoop.createAsyncTCPSocket(address.getAddressFamily(), candidate)); |
| 30 | |
| 31 | SocketServer server(candidate); |
| 32 | lastError = server.bind(address); |
| 33 | if (lastError) |
| 34 | { |
| 35 | SC_TRY(server.listen(1)); |
| 36 | return Result::Explicit(serverSocket.assign(move(candidate))); |
| 37 | } |
| 38 | } |
| 39 | return lastError; |
| 40 | } |
| 41 | |
| 42 | static AwaitTask echoServer(AwaitEventLoop& await, const SocketDescriptor& serverSocket, SocketDescriptor& accepted) |
| 43 | { |
no test coverage detected