Set SO_REUSEADDR on http port

This commit is contained in:
JP Meijers 2026-02-20 17:21:48 +02:00
parent b908baf182
commit c17be43767
No known key found for this signature in database
GPG Key ID: 57E7B2C7D93F3D34
1 changed files with 6 additions and 0 deletions

View File

@ -72,6 +72,12 @@ bool server_http_context::init(const common_params & params) {
srv.reset(new httplib::Server());
#endif
// Enable address reuse to allow immediate restart of server
srv->set_socket_options([](socket_t sock) {
int val = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
});
srv->set_default_headers({{"Server", "llama.cpp"}});
srv->set_logger(log_server_request);
srv->set_exception_handler([](const httplib::Request &, httplib::Response & res, const std::exception_ptr & ep) {