# HG changeset patch # User Teemu Piippo # Date 1418271212 -7200 # Node ID 01e4e9ae323ac49b22eb31d148319723ab2dfd00 # Parent c709bb1a08e4ad1a9fb0cc9c5ce9668f30b9ce27 - fixed some problems with the ip address diff -r c709bb1a08e4 -r 01e4e9ae323a sources/network/ipaddress.cpp --- 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; } diff -r c709bb1a08e4 -r 01e4e9ae323a sources/network/ipaddress.h --- a/sources/network/ipaddress.h Thu Dec 11 05:59:43 2014 +0200 +++ b/sources/network/ipaddress.h Thu Dec 11 06:13:32 2014 +0200 @@ -2,6 +2,7 @@ #include "../main.h" struct sockaddr; +struct sockaddr_in; enum WithPort { IP_WITH_PORT, IP_NO_PORT };