From 67b657dad02fc2ceea9583a1136d4e29871a6433 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Wed, 30 Nov 2022 11:47:59 -0800 Subject: [PATCH] SO_DOMAIN do not support on IBM i, using getsockname instead (#8437) (#8500) --- include/xgboost/collective/socket.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/xgboost/collective/socket.h b/include/xgboost/collective/socket.h index e058e58a843f..33d14fe8ca19 100644 --- a/include/xgboost/collective/socket.h +++ b/include/xgboost/collective/socket.h @@ -287,11 +287,22 @@ class TCPSocket { #elif defined(__APPLE__) return domain_; #elif defined(__unix__) +#ifndef __PASE__ std::int32_t domain; socklen_t len = sizeof(domain); xgboost_CHECK_SYS_CALL( getsockopt(handle_, SOL_SOCKET, SO_DOMAIN, reinterpret_cast(&domain), &len), 0); return ret_iafamily(domain); +#else + struct sockaddr sa; + socklen_t sizeofsa = sizeof(sa); + xgboost_CHECK_SYS_CALL( + getsockname(handle_, &sa, &sizeofsa), 0); + if (sizeofsa < sizeof(uchar_t)*2) { + return ret_iafamily(AF_INET); + } + return ret_iafamily(sa.sa_family); +#endif // __PASE__ #else LOG(FATAL) << "Unknown platform."; return ret_iafamily(AF_INET);