GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Feature Request: Add callback for successful server start event · Issue #2467 · yhirose/cpp-httplib Closed DescriptionIs your feature request related to a problem? Please describe.Currently, when using This makes it inconvenient when:
Describe the solution you'd likeI propose adding a callback mechanism similar to the existing // Option 1: A simple setter svr.set_start_handler([]() { std::cout << "Server successfully started on port 8080" << std::endl; }); // Option 2: Pass callback as parameter to listen() svr.listen("0.0.0.0", 8080, []() { std::cout << "Server is now ready" << std::endl; }); The callback should be invoked immediately after the socket binds successfully and the server begins accepting connections (or is ready to do so). Describe alternatives you've consideredCurrently, the best workarounds are:
std::thread t([&]() { svr.listen("0.0.0.0", 8080); }); svr.wait_until_ready(); std::cout << "Server ready" << std::endl;
if (svr.listen("0.0.0.0", 8080)) { // This runs immediately, but before any actual serving happens? std::cout << "Server started" << std::endl; } However, these approaches require extra synchronization logic or rely on behavior that isn't explicitly documented for this purpose. A dedicated callback would be cleaner and more intuitive. Additional contextThis feature exists in many other HTTP server libraries (e.g., Node.js Thank you for maintaining this excellent library! Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |