]> git.tdb.fi Git - libs/net.git/blobdiff - source/resolve.cpp
Drop Id tags and copyright notices
[libs/net.git] / source / resolve.cpp
index 121b152b154c12d5e47867352ceae68d78e9ea63..5bdf051b16ebc4892769a2541ed133a8941647ec 100644 (file)
@@ -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 <ws2tcpip.h>
@@ -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;