49 void AsyncAccept(SelectIoContextForNewSocket&& selectIoContext, Callback&& acceptCallback)
53 selectIoContext = std::forward<SelectIoContextForNewSocket>(selectIoContext),
54 acceptCallback = std::forward<Callback>(acceptCallback)](boost::system::error_code
const& error,
IoContextTcpSocket&& socket)
mutable
60 socket.non_blocking(true);
62 acceptCallback(std::move(socket));
64 catch (boost::system::system_error const& err)
66 TC_LOG_INFO(
"network",
"Failed to initialize client's socket {}", err.what());
71 this->
AsyncAccept(std::move(selectIoContext), std::move(acceptCallback));
77 boost::system::error_code errorCode;
78 _acceptor.open(_endpoint.protocol(), errorCode);
81 TC_LOG_INFO(
"network",
"Failed to open acceptor {}", errorCode.message());
85#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
86 _acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(
true), errorCode);
89 TC_LOG_INFO(
"network",
"Failed to set reuse_address option on acceptor {}", errorCode.message());
96 if (_endpoint.protocol() == boost::asio::ip::tcp::v6())
98 _acceptor.set_option(boost::asio::ip::v6_only(
false), errorCode);
101 TC_LOG_INFO(
"network",
"Could not disable v6_only option {}", errorCode.message());
106 _acceptor.bind(_endpoint, errorCode);
109 TC_LOG_INFO(
"network",
"Could not bind to {}:{} {}", _endpoint.address(), _endpoint.port(), errorCode.message());
116 TC_LOG_INFO(
"network",
"Failed to start listening on {}:{} {}", _endpoint.address(), _endpoint.port(), errorCode.message());