http-server.c

Basic HTTP server and router in C
git clone git://git.finwo.net/lib/http-server.c
Log | Files | Refs | README

commit 08a6762bc23f0cf43999210cdc0771babf94926b
parent e48d5a9827376162a95f9b990193d6efa8eefa17
Author: Yersa Nordman <yersa@finwo.nl>
Date:   Thu, 26 Oct 2023 23:15:35 +0200

Fix sleep; fix fnet thread init

Diffstat:
Mexample.c | 4++--
Msrc/http-server.c | 6+++++-
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/example.c b/example.c @@ -17,7 +17,7 @@ void onServing(char *addr, uint16_t port, void *udata) { printf("Serving at %s:%d\n", addr, port); } -const int countDownOrg = 60; +const int countDownOrg = 20; int countDown = countDownOrg; void onTick(void *udata) { struct http_server_opts *opts = udata; @@ -86,7 +86,7 @@ int main() { // Launch network management thread thd_thread thread; - thd_thread_detach(&thread, http_server_fnet_thread, NULL); + thd_thread_detach(&thread, fnet_thread, NULL); http_server_main(&opts); fnet_shutdown(); diff --git a/src/http-server.c b/src/http-server.c @@ -1,3 +1,7 @@ +#if defined(_WIN32) || defined(_WIN64) +#include <windows.h> +#endif + #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -11,7 +15,7 @@ static void sleep_ms(long ms) { #if defined(__APPLE__) usleep(ms * 1000); -#elif defined(_WIN32) +#elif defined(_WIN32) || defined(_WIN64) Sleep(ms); #else time_t sec = (int)(ms / 1000);