- return format("%d.%d.%d.%d:%d", static_cast<int>(ptr[0]), static_cast<int>(ptr[1]), static_cast<int>(ptr[2]), static_cast<int>(ptr[3]), ntohs(port));
+ string result = format("%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);
+ if(port)
+ result += format(":%d", ntohs(port));
+ return result;