From 14b0ed6fad8fab2a22595f6a2a0407cf1b211763 Mon Sep 17 00:00:00 2001 From: dweatherford Date: Fri, 19 Oct 2007 01:03:32 +0000 Subject: [PATCH] [thrift] TSocket host and port getters Summary: "Porting" this feature from PHP; I find it useful in the Synapse client. Reviewed By: mcslee Test Plan: It compiles, ship it! Revert: svn git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665304 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/transport/TSocket.cpp | 8 ++++++++ lib/cpp/src/transport/TSocket.h | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/cpp/src/transport/TSocket.cpp b/lib/cpp/src/transport/TSocket.cpp index 540bb6e9..7da6d37f 100644 --- a/lib/cpp/src/transport/TSocket.cpp +++ b/lib/cpp/src/transport/TSocket.cpp @@ -394,6 +394,14 @@ void TSocket::write(const uint8_t* buf, uint32_t len) { } } +std::string TSocket::getHost() { + return host_; +} + +int TSocket::getPort() { + return port_; +} + void TSocket::setHost(string host) { host_ = host; } diff --git a/lib/cpp/src/transport/TSocket.h b/lib/cpp/src/transport/TSocket.h index 511e4a9a..57ff1272 100644 --- a/lib/cpp/src/transport/TSocket.h +++ b/lib/cpp/src/transport/TSocket.h @@ -86,6 +86,20 @@ class TSocket : public TTransport { */ void write(const uint8_t* buf, uint32_t len); + /** + * Get the host that the socket is connected to + * + * @return string host identifier + */ + std::string getHost(); + + /** + * Get the port that the socket is connected to + * + * @return int port number + */ + int getPort(); + /** * Set the host that socket will connect to * -- 2.17.1