X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresolve.cpp;h=5bdf051b16ebc4892769a2541ed133a8941647ec;hb=2aab4004e71a2e5c773289e0be5e58aec6a8d339;hp=121b152b154c12d5e47867352ceae68d78e9ea63;hpb=f59eded7c3e162bbdfc6db424c9badc730017698;p=libs%2Fnet.git diff --git a/source/resolve.cpp b/source/resolve.cpp index 121b152..5bdf051 100644 --- a/source/resolve.cpp +++ b/source/resolve.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspnet -Copyright © 2008 Mikkosoft Productions, Mikko Rasa -Distributed under the LGPL -*/ - #ifdef WIN32 #define _WIN32_WINNT 0x0501 #include @@ -23,14 +16,25 @@ namespace Net { SockAddr *resolve(const string &s, Family family) { string host, serv; - unsigned colon=s.find(':'); - if(colon!=string::npos) + if(s[0]=='[') { - host=s.substr(0, colon); - serv=s.substr(colon+1); + unsigned bracket = s.find(']'); + host = s.substr(1, bracket-1); + unsigned colon = s.find(':', bracket); + if(colon!=string::npos) + serv = s.substr(colon+1); } else - host=s; + { + unsigned colon = s.find(':'); + if(colon!=string::npos) + { + host = s.substr(0, colon); + serv = s.substr(colon+1); + } + else + host = s; + } addrinfo hints={0, family, 0, 0, 0, 0, 0, 0}; addrinfo *res;