diff options
Diffstat (limited to 'src/network/core/address.cpp')
-rw-r--r-- | src/network/core/address.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp new file mode 100644 index 000000000..637f0fe7b --- /dev/null +++ b/src/network/core/address.cpp @@ -0,0 +1,30 @@ +/* $Id$ */ + +/** @file core/address.cpp Implementation of the address. */ + +#include "../../stdafx.h" + +#ifdef ENABLE_NETWORK + +#include "address.h" +#include "host.h" + +const char *NetworkAddress::GetHostname() const +{ + if (this->hostname != NULL) return this->hostname; + + in_addr addr; + addr.s_addr = this->ip; + return inet_ntoa(addr); +} + +uint32 NetworkAddress::GetIP() +{ + if (!this->resolved) { + this->ip = NetworkResolveHost(this->hostname); + this->resolved = true; + } + return this->ip; +} + +#endif /* ENABLE_NETWORK */ |