summaryrefslogtreecommitdiff
path: root/src/network/core/address.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-20 11:28:18 +0000
committerrubidium <rubidium@openttd.org>2009-01-20 11:28:18 +0000
commit28a641066e2e9963f6662366281079b7d00ac835 (patch)
tree6b344cc0bfeff2bffba2764265342a0ed65238d2 /src/network/core/address.cpp
parentc9436c8d88961032ab66f4d06892615d239014ab (diff)
downloadopenttd-28a641066e2e9963f6662366281079b7d00ac835.tar.xz
(svn r15163) -Change/Fix: use a non-blocking method to resolve the hostname and connect to game servers.
Diffstat (limited to 'src/network/core/address.cpp')
-rw-r--r--src/network/core/address.cpp30
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 */