| 831 | } |
| 832 | |
| 833 | string TSocket::getSocketInfo() const { |
| 834 | std::ostringstream oss; |
| 835 | if (!isUnixDomainSocket()) { |
| 836 | if (host_.empty() || port_ == 0) { |
| 837 | oss << "<Host: " << getPeerAddress(); |
| 838 | oss << " Port: " << getPeerPort() << ">"; |
| 839 | } else { |
| 840 | oss << "<Host: " << host_ << " Port: " << port_ << ">"; |
| 841 | } |
| 842 | } else { |
| 843 | std::string fmt_path_ = path_; |
| 844 | // Handle printing abstract sockets (first character is a '\0' char): |
| 845 | if (!fmt_path_.empty() && fmt_path_[0] == '\0') |
| 846 | fmt_path_[0] = '@'; |
| 847 | oss << "<Path: " << fmt_path_ << ">"; |
| 848 | } |
| 849 | return oss.str(); |
| 850 | } |
| 851 | |
| 852 | std::string TSocket::getPeerHost() const { |
| 853 | if (peerHost_.empty() && !isUnixDomainSocket()) { |
no test coverage detected