[Coll] Implement get host address in libxgboost. (#9644)

- Port `xgboost.tracker.get_host_ip` in C++.
This commit is contained in:
Jiaming Yuan
2023-10-10 10:01:14 +08:00
committed by GitHub
parent 680d53db43
commit b14e535e78
6 changed files with 199 additions and 31 deletions

View File

@@ -0,0 +1,18 @@
/**
* Copyright 2023, XGBoost Contributors
*/
#include "../../../src/collective/tracker.h" // for GetHostAddress
#include "net_test.h" // for SocketTest
namespace xgboost::collective {
namespace {
class TrackerTest : public SocketTest {};
} // namespace
TEST_F(TrackerTest, GetHostAddress) {
std::string host;
auto rc = GetHostAddress(&host);
ASSERT_TRUE(rc.OK());
ASSERT_TRUE(host.find("127.") == std::string::npos);
}
} // namespace xgboost::collective