jeremycw / httpserver.h

Single header library for writing non-blocking HTTP servers in C
MIT License
1.78k stars 143 forks source link

SO_REUSEPORT is not defined on Ubuntu #62

Open nickav opened 1 year ago

nickav commented 1 year ago

When compiling on WSL2 Ubuntu I get the following error:

nick:~/dev/_lib/httpserver.h master$ make
cc -O3 -std=c99 -Wall -Wextra -Werror test/main.c -o http-server
In file included from test/main.c:2:
test/../httpserver.h: In function ‘http_listen’:
test/../httpserver.h:1223:40: error: ‘SO_REUSEPORT’ undeclared (first use in this function); did you mean ‘SO_REUSEADDR’?
 1223 |   setsockopt(serv->socket, SOL_SOCKET, SO_REUSEPORT, &flag, sizeof(flag));
      |                                        ^~~~~~~~~~~~
      |                                        SO_REUSEADDR
test/../httpserver.h:1223:40: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Makefile:24: http-server] Error 1

Should this be replaced with SO_REUSEADDR? I'm not sure if they are the same