diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 11f9b9f44..62489ecc5 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -1761,7 +1761,13 @@ float Socket::getAveragePingMS(std::string host, int pingCount) { sprintf(szCmd,"ping -c %d %s",pingCount,host.c_str()); #endif if(szCmd[0] != '\0') { +#ifdef _popen + FILE *ping= _popen(szCmd, "r"); +#elif defined popen FILE *ping= popen(szCmd, "r"); +#else + FILE *ping=NULL; +#endif if (ping != NULL){ char buf[4000]=""; int bufferPos = 0; @@ -1769,7 +1775,11 @@ float Socket::getAveragePingMS(std::string host, int pingCount) { char *data = fgets(&buf[bufferPos], 256, ping); bufferPos = strlen(buf); } +#ifdef _pclose + _pclose(ping); +#elif defined popen pclose(ping); +#endif if(debugPingOutput) printf("Running cmd [%s] got [%s]\n",szCmd,buf);