Make poll() the default

select() can still be enabled by defining CPPHTTPLIB_USE_SELECT.
This commit is contained in:
Florian Albrechtskirchinger 2025-02-17 08:51:28 +01:00
parent 32bf5c9c09
commit e0e7ebcf29
No known key found for this signature in database
GPG Key ID: 9C4E2AE92D3A9595
3 changed files with 10 additions and 4 deletions

View File

@ -2,7 +2,7 @@ FROM yhirose4dockerhub/ubuntu-builder AS builder
WORKDIR /build
COPY httplib.h .
COPY docker/main.cc .
RUN g++ -std=c++23 -static -o server -O2 -I. -DCPPHTTPLIB_USE_POLL main.cc && strip server
RUN g++ -std=c++23 -static -o server -O2 -I. main.cc && strip server
FROM scratch
COPY --from=builder /build/server /server

View File

@ -872,10 +872,10 @@ res->body; // Compressed data
```
Use `poll` instead of `select`
------------------------------
Use `select()` instead of `poll()`
----------------------------------
`select` system call is used as default since it's more widely supported. If you want to let cpp-httplib use `poll` instead, you can do so with `CPPHTTPLIB_USE_POLL`.
cpp-httplib defaults to the widely supported `poll()` system call. If your OS lacks support for `poll()`, define `CPPHTTPLIB_USE_SELECT` to use `select()` instead.
Unix Domain Socket Support
--------------------------

View File

@ -145,6 +145,12 @@
#define CPPHTTPLIB_LISTEN_BACKLOG 5
#endif
#if !defined(CPPHTTPLIB_USE_POLL) && !defined(CPPHTTPLIB_USE_SELECT)
#define CPPHTTPLIB_USE_POLL
#elif defined(CPPHTTPLIB_USE_POLL) && defined(CPPHTTPLIB_USE_SELECT)
#error "CPPHTTPLIB_USE_POLL and CPPHTTPLIB_USE_SELECT are mutually exclusive"
#endif
/*
* Headers
*/