Hi, No, not from the service method, but I was under the impression that you could access it from within a processor event. That's not the case with C++, sorry.
However, did you check SO and the mailing list archives? - https://stackoverflow.com/questions/27701338/how-to-get-client-ip-address-with-c-in-thrift - https://grokbase.com/t/thrift/user/11aqrp2782/how-can-i-get-the-clients-ip-from-the-server-of-thrift - https://stackoverflow.com/questions/27701338/how-to-get-client-ip-address-with-c-in-thrift That question arises every now and then so there should be plenty of search result. JensG -----Ursprüngliche Nachricht----- From: Gianni Ambrosio Sent: Wednesday, April 3, 2019 11:49 AM To: [email protected] Subject: Re: how to get IP and port from ServiceIf call? 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 >
