sources/network/ipaddress.cpp

changeset 7
01e4e9ae323a
parent 5
146825d63b9a
child 8
8b697d30c49f
--- a/sources/network/ipaddress.cpp	Thu Dec 11 05:59:43 2014 +0200
+++ b/sources/network/ipaddress.cpp	Thu Dec 11 06:13:32 2014 +0200
@@ -118,8 +118,7 @@
 	String addressString = colonpos == -1 ? input : input.mid (0, colonpos);
 	IPAddress value;
 
-	// Try scanf the IPv4 host first. If it's not an IP string, it could
-	// be a hostname; thus try resolve it.
+	// Try scanf the IPv4 host first
 	if (sscanf (addressString, "%u.%u.%u.%u", &parts[0], &parts[1], &parts[2], &parts[3]))
 	{
 		for (short i = 0; i < 4; ++i)
@@ -127,12 +126,15 @@
 	}
 	else
 	{
-		// try resolve it
-		return IPAddress::resolve (addressString, ok);
+		// Possibly a hostname, try resolve it
+		value = IPAddress::resolve (addressString, ok);
+
+		if (*ok == false)
+			return value;
 	}
 
 	if (colonpos != -1)
-		value.port = atoi (input.mid (colonpos + 1, -1));
+		value.port = input.mid (colonpos + 1, -1).to_int();
 
 	return value;
 }

mercurial