Fixed problem with set_socket_options
This commit is contained in:
parent
bfabbec8c7
commit
4a9c048bbc
24
httplib.h
24
httplib.h
@ -1889,11 +1889,11 @@ inline bool process_server_socket_core(socket_t sock,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool
|
inline bool process_server_socket(socket_t sock, size_t keep_alive_max_count,
|
||||||
process_server_socket(socket_t sock, size_t keep_alive_max_count,
|
time_t read_timeout_sec,
|
||||||
time_t read_timeout_sec, time_t read_timeout_usec,
|
time_t read_timeout_usec,
|
||||||
time_t write_timeout_sec, time_t write_timeout_usec,
|
time_t write_timeout_sec,
|
||||||
T callback) {
|
time_t write_timeout_usec, T callback) {
|
||||||
return process_server_socket_core(
|
return process_server_socket_core(
|
||||||
sock, keep_alive_max_count,
|
sock, keep_alive_max_count,
|
||||||
[&](bool close_connection, bool connection_closed) {
|
[&](bool close_connection, bool connection_closed) {
|
||||||
@ -1974,16 +1974,6 @@ socket_t create_socket(const char *host, int port, int socket_flags,
|
|||||||
|
|
||||||
if (socket_options) { socket_options(sock); }
|
if (socket_options) { socket_options(sock); }
|
||||||
|
|
||||||
// Make 'reuse address' option available
|
|
||||||
int yes = 1;
|
|
||||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&yes),
|
|
||||||
sizeof(yes));
|
|
||||||
|
|
||||||
#ifdef SO_REUSEPORT
|
|
||||||
setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast<char *>(&yes),
|
|
||||||
sizeof(yes));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (rp->ai_family == AF_INET6) {
|
if (rp->ai_family == AF_INET6) {
|
||||||
int no = 0;
|
int no = 0;
|
||||||
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<char *>(&no),
|
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<char *>(&no),
|
||||||
@ -3695,6 +3685,10 @@ inline void Server::set_error_handler(Handler handler) {
|
|||||||
error_handler_ = std::move(handler);
|
error_handler_ = std::move(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Server::set_socket_options(SocketOptions socket_options) {
|
||||||
|
socket_options_ = socket_options;
|
||||||
|
}
|
||||||
|
|
||||||
inline void Server::set_logger(Logger logger) { logger_ = std::move(logger); }
|
inline void Server::set_logger(Logger logger) { logger_ = std::move(logger); }
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user