Use const for option. Include proper header files.
This commit is contained in:
parent
fe397e6953
commit
520b29d0d5
@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -50,11 +53,10 @@ class Server
|
|||||||
|
|
||||||
acceptor.open(endpoint.protocol());
|
acceptor.open(endpoint.protocol());
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
int one = 1;
|
const int option = 1;
|
||||||
setsockopt(acceptor.native_handle(), SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &one, sizeof(one));
|
setsockopt(acceptor.native_handle(), SOL_SOCKET, SO_REUSEPORT, &option, sizeof(option));
|
||||||
#else
|
|
||||||
acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
|
|
||||||
#endif
|
#endif
|
||||||
|
acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
|
||||||
acceptor.bind(endpoint);
|
acceptor.bind(endpoint);
|
||||||
acceptor.listen();
|
acceptor.listen();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user