I'm trying to play with the library by creating a sample program that has an infinite while loop in its main function. The main goal would be to create a new webserver with the params passed on user input. Unfortunately, it seems that the webserver is not starting in this loop.
Expected behavior: the webserver starts correctly, and is accessible on endpoint, address and port specified by user input.
Actual behavior: The webserver doesn't start.
Versions
OS version : Linux devserver 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
libhttpserver version : compiled (latest available)
Additional Information
I've noticed that the code provided above works if I declare the webserver object before the while loop (the rest of the code can be executed in the while loop without any problem). However, by doing so, the program loses its interest. I don't know whether this is a bug or an inherent feature of the library, and I'd be interested in possible solutions.
You are creating the webserver object within the loop. That means that you destroy the object at each iteration. You can either store them in a variable outside the loop or allocate it dynamically.
Prerequisites
Description
I'm trying to play with the library by creating a sample program that has an infinite while loop in its main function. The main goal would be to create a new webserver with the params passed on user input. Unfortunately, it seems that the webserver is not starting in this loop.
Steps to Reproduce
Sample code used :
Expected behavior: the webserver starts correctly, and is accessible on endpoint, address and port specified by user input.
Actual behavior: The webserver doesn't start.
Versions
Additional Information
I've noticed that the code provided above works if I declare the webserver object before the while loop (the rest of the code can be executed in the while loop without any problem). However, by doing so, the program loses its interest. I don't know whether this is a bug or an inherent feature of the library, and I'd be interested in possible solutions.