Skip to content

Commit e0e7ebc

Browse files
Make poll() the default
select() can still be enabled by defining CPPHTTPLIB_USE_SELECT.
1 parent 32bf5c9 commit e0e7ebc

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM yhirose4dockerhub/ubuntu-builder AS builder
22
WORKDIR /build
33
COPY httplib.h .
44
COPY docker/main.cc .
5-
RUN g++ -std=c++23 -static -o server -O2 -I. -DCPPHTTPLIB_USE_POLL main.cc && strip server
5+
RUN g++ -std=c++23 -static -o server -O2 -I. main.cc && strip server
66

77
FROM scratch
88
COPY --from=builder /build/server /server

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,10 @@ res->body; // Compressed data
872872

873873
```
874874

875-
Use `poll` instead of `select`
876-
------------------------------
875+
Use `select()` instead of `poll()`
876+
----------------------------------
877877

878-
`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`.
878+
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.
879879

880880
Unix Domain Socket Support
881881
--------------------------

httplib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@
145145
#define CPPHTTPLIB_LISTEN_BACKLOG 5
146146
#endif
147147

148+
#if !defined(CPPHTTPLIB_USE_POLL) && !defined(CPPHTTPLIB_USE_SELECT)
149+
#define CPPHTTPLIB_USE_POLL
150+
#elif defined(CPPHTTPLIB_USE_POLL) && defined(CPPHTTPLIB_USE_SELECT)
151+
#error "CPPHTTPLIB_USE_POLL and CPPHTTPLIB_USE_SELECT are mutually exclusive"
152+
#endif
153+
148154
/*
149155
* Headers
150156
*/

0 commit comments

Comments
 (0)