diff --git a/CMakeLists.txt b/CMakeLists.txt index f8b4d34..05f0c2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,10 @@ include_directories("${PROJECT_BINARY_DIR}") add_executable(SpeedTest ${SOURCE_FILES}) +if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + target_link_libraries(SpeedTest socket nsl) +endif() + INCLUDE (CheckIncludeFiles) find_package(CURL REQUIRED) find_package(LibXml2 REQUIRED) diff --git a/SpeedTestClient.cpp b/SpeedTestClient.cpp index 39ffc14..c29b399 100644 --- a/SpeedTestClient.cpp +++ b/SpeedTestClient.cpp @@ -189,6 +189,18 @@ bool SpeedTestClient::mkSocket() { if (server == nullptr) { return false; } +#elif defined(__sun) || defined(__illumos__) + struct hostent server; + char tmpbuf[BUFSIZ]; + int errnop = 0; + + /* illumos/Solaris: gethostbyname_r returns hostent* and takes (.., int *h_errnop) */ + struct hostent *result = gethostbyname_r( + hostp.first.c_str(), &server, (char *)&tmpbuf, BUFSIZ, &errnop + ); + if (result == nullptr) { + return false; + } #else struct hostent server; char tmpbuf[BUFSIZ];