| 20 | namespace SC |
| 21 | { |
| 22 | static Result createServer(AsyncEventLoop& eventLoop, SocketDescriptor& serverSocket, SocketIPAddress& address) |
| 23 | { |
| 24 | constexpr uint16_t firstPort = 39171; |
| 25 | constexpr uint16_t numPorts = 64; |
| 26 | |
| 27 | Result lastError = Result::Error("Could not bind AwaitFileCourier socket"); |
| 28 | for (uint16_t offset = 0; offset < numPorts; ++offset) |
| 29 | { |
| 30 | const uint16_t port = static_cast<uint16_t>(firstPort + offset); |
| 31 | SC_TRY(address.fromAddressPort("127.0.0.1", port)); |
| 32 | |
| 33 | SocketDescriptor candidate; |
| 34 | SC_TRY(eventLoop.createAsyncTCPSocket(address.getAddressFamily(), candidate)); |
| 35 | |
| 36 | SocketServer server(candidate); |
| 37 | lastError = server.bind(address); |
| 38 | if (lastError) |
| 39 | { |
| 40 | SC_TRY(server.listen(1)); |
| 41 | return Result::Explicit(serverSocket.assign(move(candidate))); |
| 42 | } |
| 43 | } |
| 44 | return lastError; |
| 45 | } |
| 46 | |
| 47 | static Result createSocketPair(AsyncEventLoop& eventLoop, SocketDescriptor& sender, SocketDescriptor& receiver) |
| 48 | { |
no test coverage detected