Compare commits

...

5 Commits

Author SHA1 Message Date
JP Meijers 577753a98f
Merge 4d7c07a2f3 into 389c7d4955 2026-03-30 22:43:22 +09:00
JP Meijers 4d7c07a2f3
Use instead SO_LINGER with timeout of 0 seconds 2026-02-24 16:05:10 +02:00
JP Meijers 0e93d6e453
Use a constant chat for flag value 2026-02-21 08:43:56 +02:00
JP Meijers bb9fcb96c5
Move socket option to bind and listen function 2026-02-20 18:06:23 +02:00
JP Meijers c17be43767
Set SO_REUSEADDR on http port 2026-02-20 17:21:48 +02:00
1 changed files with 9 additions and 0 deletions

View File

@ -305,6 +305,15 @@ bool server_http_context::start() {
was_bound = srv->bind_to_port(hostname, 8080);
} else {
LOG_INF("%s: binding port with default address family\n", __func__);
// Set linger time to 0 to force close the socket immediately when the server stops
srv->set_socket_options([](socket_t sock) {
linger sl{};
sl.l_onoff = 1;
sl.l_linger = 0;
setsockopt(sock, SOL_SOCKET, SO_LINGER, reinterpret_cast<const char *>(&sl), sizeof(sl));
});
// bind HTTP listen port
if (port == 0) {
int bound_port = srv->bind_to_any_port(hostname);