| 36 | } |
| 37 | |
| 38 | Result HttpAsyncServer::start(AsyncEventLoop& loop, StringSpan address, uint16_t port) |
| 39 | { |
| 40 | SC_TRY_MSG(state == State::Stopped, "HttpAsyncServer::start requires stopped state"); |
| 41 | SC_TRY_MSG(connections.getNumTotalConnections() > 0, "HttpAsyncServer::start - init not called"); |
| 42 | SocketIPAddress nativeAddress; |
| 43 | SC_TRY(nativeAddress.fromAddressPort(address, port)); |
| 44 | eventLoop = &loop; |
| 45 | SC_TRY(eventLoop->createAsyncTCPSocket(nativeAddress.getAddressFamily(), serverSocket)); |
| 46 | SocketServer socketServer(serverSocket); |
| 47 | SC_TRY(socketServer.bind(nativeAddress)); |
| 48 | SC_TRY(socketServer.listen(511)); |
| 49 | |
| 50 | asyncServerAccept.setDebugName("HttpConnectionsPool"); |
| 51 | asyncServerAccept.callback.bind<HttpAsyncServer, &HttpAsyncServer::onNewClient>(*this); |
| 52 | SC_TRY(asyncServerAccept.start(*eventLoop, serverSocket)); |
| 53 | state = State::Started; |
| 54 | return Result(true); |
| 55 | } |
| 56 | |
| 57 | Result HttpAsyncServer::close() |
| 58 | { |
no test coverage detected