diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index f2dade58c..d76c71d53 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -152,6 +152,8 @@ protected: bool isSocketBlocking; time_t lastSocketError; + static string host_name; + public: Socket(PLATFORM_SOCKET sock); Socket(); diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 0ae9889bc..691a208d1 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -68,6 +68,7 @@ namespace Shared{ namespace Platform{ bool Socket::disableNagle = false; int Socket::DEFAULT_SOCKET_SENDBUF_SIZE = -1; int Socket::DEFAULT_SOCKET_RECVBUF_SIZE = -1; +string Socket::host_name = ""; int Socket::broadcast_portno = 61357; int ServerSocket::ftpServerPort = 61358; @@ -1827,19 +1828,18 @@ bool Socket::isConnected() { } string Socket::getHostName() { - static string host = ""; - if(host == "") { + if(Socket::host_name == "") { const int strSize= 257; char hostname[strSize]=""; int result = gethostname(hostname, strSize); if(result == 0) { - host = (hostname[0] != '\0' ? hostname : ""); + Socket::host_name = (hostname[0] != '\0' ? hostname : ""); } else { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] result = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,result,getLastSocketErrorText()); } } - return host; + return Socket::host_name; } string Socket::getIp() {