To connect to the metaserver, try on all interfaces unless one was passed on the commandline

This commit is contained in:
Tim Felgentreff 2016-11-11 18:22:26 +01:00
parent 39aa96fb62
commit c9c4bc3731

View file

@ -97,7 +97,13 @@ int CMetaClient::Init()
// Server socket
CHost metaServerHost(metaHost.c_str(), metaPort);
// Client socket
CHost metaClientHost(CNetworkParameter::Instance.localHost.c_str(), CNetworkParameter::Instance.localPort);
// open on all interfaces, not the loopback, unless we have an override from the commandline
std::string localHost = CNetworkParameter::Instance.localHost;
if (!localHost.compare("127.0.0.1")) {
localHost = "0.0.0.0";
}
CHost metaClientHost(localHost.c_str(), CNetworkParameter::Instance.localPort);
metaSocket.Open(metaClientHost);
if (metaSocket.IsValid() == false) {
fprintf(stderr, "METACLIENT: No free port %d available, aborting\n", metaServerHost.getPort());