summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpid/Address.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src/qpid/Address.cpp')
-rw-r--r--qpid/cpp/src/qpid/Address.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/qpid/cpp/src/qpid/Address.cpp b/qpid/cpp/src/qpid/Address.cpp
index e2b2dfbcdf..bed3d592df 100644
--- a/qpid/cpp/src/qpid/Address.cpp
+++ b/qpid/cpp/src/qpid/Address.cpp
@@ -28,7 +28,13 @@ namespace qpid {
const string Address::TCP("tcp");
ostream& operator<<(ostream& os, const Address& a) {
- return os << a.protocol << ":" << a.host << ":" << a.port;
+ // If the host is an IPv6 literal we need to print "[]" around it
+ // (we detect IPv6 literals because they contain ":" which is otherwise illegal)
+ if (a.host.find(':') != string::npos) {
+ return os << a.protocol << ":[" << a.host << "]:" << a.port;
+ } else {
+ return os << a.protocol << ":" << a.host << ":" << a.port;
+ }
}
bool operator==(const Address& x, const Address& y) {