mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 13:50:43 +02:00
- small network optimization to help stabilize frequently called network code
This commit is contained in:
@@ -1228,16 +1228,18 @@ bool Socket::isConnected() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string Socket::getHostName() {
|
string Socket::getHostName() {
|
||||||
|
static string host = "";
|
||||||
|
if(host == "") {
|
||||||
const int strSize= 257;
|
const int strSize= 257;
|
||||||
char hostname[strSize]="";
|
char hostname[strSize]="";
|
||||||
int result = gethostname(hostname, strSize);
|
int result = gethostname(hostname, strSize);
|
||||||
string host = "";
|
|
||||||
if(result == 0) {
|
if(result == 0) {
|
||||||
host = (hostname[0] != '\0' ? hostname : "");
|
host = (hostname[0] != '\0' ? hostname : "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] result = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,result,getLastSocketErrorText());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] result = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,result,getLastSocketErrorText());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user