sources/network/ipaddress.cpp

changeset 24
e651d02802c0
parent 19
2046a1651c0b
child 73
07dda51a7a8e
--- a/sources/network/ipaddress.cpp	Sun Dec 14 20:47:44 2014 +0200
+++ b/sources/network/ipaddress.cpp	Sun Dec 14 23:21:38 2014 +0200
@@ -36,8 +36,6 @@
 #include <netdb.h>
 #include "ipaddress.h"
 
-bool IPAddress::sink;
-
 // -----------------------------------------------------------------------------
 //
 IPAddress::IPAddress() :
@@ -140,7 +138,7 @@
 // -----------------------------------------------------------------------------
 //
 STATIC METHOD
-IPAddress::from_string (String input, bool* ok) -> IPAddress
+IPAddress::from_string (String input) -> IPAddress
 {
 	unsigned int parts[4];
 	int colonpos = input.find (":");
@@ -156,10 +154,7 @@
 	else
 	{
 		// Possibly a hostname, try resolve it
-		value = IPAddress::resolve (addressString, ok);
-
-		if (*ok == false)
-			return value;
+		value = IPAddress::resolve (addressString);
 	}
 
 	if (colonpos != -1)
@@ -171,7 +166,7 @@
 // -----------------------------------------------------------------------------
 //
 STATIC METHOD
-IPAddress::resolve (String node, bool* ok) -> IPAddress
+IPAddress::resolve (String node) -> IPAddress
 {
 	addrinfo hints;
 	addrinfo* lookup;
@@ -179,10 +174,7 @@
 	hints.ai_family = AF_INET;
 
 	if (getaddrinfo (node, nullptr, &hints, &lookup) != 0)
-	{
-		*ok = false;
-		return IPAddress();
-	}
+		throw StringParseError ("unknown host " + node);
 
 	IPAddress result;
 	assert (lookup != nullptr);

mercurial