Enclose host in [] if host is IPv6 literal address.

This commit is contained in:
Tatsuhiro Tsujikawa 2012-02-15 00:14:27 +09:00
parent bfc3b4b95b
commit 8069575838
1 changed files with 8 additions and 1 deletions

View File

@ -161,7 +161,14 @@ int communicate(const std::string& host, uint16_t port,
pollfd pollfds[1];
std::stringstream ss;
ss << host << ":" << port;
if(reqvec[0].us.ipv6LiteralAddress) {
ss << "[";
}
ss << host;
if(reqvec[0].us.ipv6LiteralAddress) {
ss << "]";
}
ss << ":" << port;
std::string hostport = ss.str();
for(int i = 0, n = reqvec.size(); i < n; ++i) {