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, string> * 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 :)

Reply via email to