X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=blobdiff_plain;f=source%2Fresolve.cpp;h=bfe7eaaa5cada587f0eef0e8585965670df526fd;hp=121b152b154c12d5e47867352ceae68d78e9ea63;hb=1b2aabf076169e6d2049227188e464e95ac40514;hpb=35009eb3f51a6fd0f9261f892a85d97d81e69886 diff --git a/source/resolve.cpp b/source/resolve.cpp index 121b152..bfe7eaa 100644 --- a/source/resolve.cpp +++ b/source/resolve.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of libmspnet -Copyright © 2008 Mikkosoft Productions, Mikko Rasa +Copyright © 2008, 2011 Mikkosoft Productions, Mikko Rasa Distributed under the LGPL */ @@ -23,14 +23,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;