\anchor http
| 956 | |
| 957 | /// \anchor http |
| 958 | void HTTPServer::ThreadSocketHandler() |
| 959 | { |
| 960 | while (!m_interrupt_net) { |
| 961 | // Check for the readiness of the already connected sockets and the |
| 962 | // listening sockets in one call ("readiness" as in poll(2) or |
| 963 | // select(2)). If none are ready, wait for a short while and return |
| 964 | // empty sets. |
| 965 | auto io_readiness{GenerateWaitSockets()}; |
| 966 | if (io_readiness.events_per_sock.empty() || |
| 967 | // WaitMany() may as well be a static method, the context of the first Sock in the vector is not relevant. |
| 968 | !io_readiness.events_per_sock.begin()->first->WaitMany(SELECT_TIMEOUT, |
| 969 | io_readiness.events_per_sock)) { |
| 970 | m_interrupt_net.sleep_for(SELECT_TIMEOUT); |
| 971 | } |
| 972 | |
| 973 | // Service (send/receive) each of the already connected sockets. |
| 974 | SocketHandlerConnected(io_readiness); |
| 975 | |
| 976 | // Accept new connections from listening sockets. |
| 977 | SocketHandlerListening(io_readiness.events_per_sock); |
| 978 | |
| 979 | // Disconnect any clients that have been flagged. |
| 980 | DisconnectClients(); |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | void HTTPServer::MaybeDispatchRequestsFromClient(const std::shared_ptr<HTTPRemoteClient>& client) const |
| 985 | { |