thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof Godlewski <>
Subject Re: Client IP address
Date Wed, 06 May 2009 18:14:51 GMT

On 2009-05-06, at 18:37, Patrick Schlangen wrote:

> Hi,
> I am implementing a thrift-based service in C++ at the moment and  
> encountered a question:
> Is there a way to get the client's IP address from inside a service  
> method implementation? I am using a TThreadedServer.

I implemented this using TServerEventHandler:
  * there's a static map that holds client addrs: map<unsigned long,  
  * client addresses are added to a map in MyHandler::clientBegin(),  
pthread_self() is the key in address map
  * addresses are removed in clientEnd()
  * a static method MyHandler::get() returns addresses[pthread_self()]

I know, it's a very primitive solution, but it works :)

View raw message