Hi Jens,
"getOrigin" is a method of TSocket. How can I get the TSocket instance
from an implementation of ThriftServiceIf generated interface? I try to
explain in detail.
In a ".thrift" file I have:
service QtService {
oneway void realTimeDataEvent(1: RealTimeData data)
}
Thrift then generates a file with:
class QtServiceIf {
public:
virtual ~QtServiceIf() {}
virtual void realTimeDataEvent(const RealTimeData& data) = 0;
}
So I implement QtServiceIf as follows:
class ThriftServiceHandler : public QtServiceIf {
public:
void realTimeDataEvent(const RealTimeData& rtData);
}
Can I call "getOrigin()" as you suggested in my "realTimeDataEvent()"
implementation to know which is the IP of the client that sent real time
data to the thrift server implementation?
Best regards,
Gianni
On 01/04/2019 22:44, Jens Geyer wrote:
> Hi Gianni,
>
> getOrigin() could be what you are looking for:
>
> https://github.com/apache/thrift/blob/042580f53441efe1bc5c80c89351fcb30740659e/lib/cpp/src/thrift/transport/TSocket.cpp#L952
>
> Have fun,
> JensG
>
>
>
>
> -----Ursprüngliche Nachricht-----
> From: Gianni Ambrosio
> Sent: Monday, April 1, 2019 3:24 PM
> To: [email protected]
> Subject: how to get IP and port from ServiceIf call?
>
> Dear All,
> I have a Thrift server implemented in C++. Many different clients can
> connect to it and call let's say "setData" method of a ServiceIf
> implementation. The server in that method must be able to associate the
> sent data to the proper client. So, is it possible to retrieve the IP
> address and port of the client or should I send them to the same
> "setData" call as parameters?
>
> Best regards,
> Gianni
>