/* $Id$
This file is part of libmspnet
-Copyright © 2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2008, 2011 Mikkosoft Productions, Mikko Rasa
Distributed under the LGPL
*/
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;