MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / start

Method start

Libraries/Http/HttpAsyncServer.cpp:38–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38Result 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
57Result HttpAsyncServer::close()
58{

Callers 6

onNewClientMethod · 0.45
deactivateConnectionMethod · 0.45
getFileMethod · 0.45
putFileMethod · 0.45
startBodyStreamMethod · 0.45
connectMethod · 0.45

Calls 5

createAsyncTCPSocketMethod · 0.80
getAddressFamilyMethod · 0.80
ResultClass · 0.50
bindMethod · 0.45
setDebugNameMethod · 0.45

Tested by

no test coverage detected