This would seem to suggest you have your own in-house portmapper- thingey. Interesting. I am considering open sourcing something that adresses, among other things, that subproblem. -bjørn -- Sent from my iPhone On 25. mai 2010, at 21.58, Richard Salz wrote: > We find ourselves writing the same code snippets over and over again. > Perhaps this is useful to others. > > For clients: > > template > xxxClient* > getClient(const char* sname, const char* host="127.0.0.1") > { > int port = applianceUtils::getPortforService(sname); /// @TODO: > XXX your "portmapper" here. > shared_ptr socket(new TSocket(host, port)); > shared_ptr bufferedSocket(new > TBufferedTransport(socket)); > bufferedSocket->open(); > shared_ptr protocol(new > TBinaryProtocol(bufferedSocket)); > return new xxxClient(protocol); > } > > Usage: > shared_ptr > c(getClient("usermanager")); > c->login(name, password); > c->logout(); > ... connection closed when "c" goes out of scope > > For servers we use this: Obviously you can add more common prolog/ > epilog > (like logging), make TSimpleServer be a template parameter, etc. > > template > static void > RunServer(int port, xxxManager* impl) > { > shared_ptr s(impl); > shared_ptr processor(new xxxManagerProcessor(s)); > shared_ptr transport(new TServerSocket > (port)); > shared_ptr tfactory(new > TBufferedTransportFactory()); > shared_ptr pfactory(new > TBinaryProtocolFactory()); > TSimpleServer server(processor, transport, tfactory, pfactory); > server.serve(); > } > > Usage: > RunServer( > applianceUtils::getPortforService("hardwaremanager"); > new hardwareManagerServer()); > > Hopefully this will save *dozens* of lines of code world-wide. :) > > /r$ > > -- > STSM, WebSphere Appliance Architect > https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/ >