mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-06 21:01:42 +02:00
fix "Address family not supported"
This commit is contained in:
parent
58b7229810
commit
1a51833f0e
2 changed files with 31 additions and 2 deletions
|
@ -138,7 +138,21 @@ void ControlServer::start()
|
|||
{
|
||||
asio::ip::address address = asio::ip::address::from_string("::");
|
||||
tcp::endpoint endpoint(address, port_);
|
||||
acceptor_ = make_shared<tcp::acceptor>(*io_service_, endpoint);
|
||||
try
|
||||
{
|
||||
acceptor_ = make_shared<tcp::acceptor>(*io_service_, endpoint);
|
||||
}
|
||||
catch (const asio::system_error& e)
|
||||
{
|
||||
LOG(ERROR) << "error creating TCP acceptor: " << e.what() << ", code: " << e.code() << "\n";
|
||||
if (e.code().value() == asio::error::address_family_not_supported)
|
||||
{
|
||||
endpoint = tcp::endpoint(tcp::v4(), port_);
|
||||
acceptor_ = make_shared<tcp::acceptor>(*io_service_, endpoint);
|
||||
}
|
||||
else
|
||||
throw;
|
||||
}
|
||||
if (endpoint.protocol() == tcp::v6())
|
||||
{
|
||||
error_code ec;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue