You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Rob Slifka <rs...@sfu.ca> on 2009/09/21 23:08:31 UTC

C++ Server Error-handling Question

Hi everyone, 

We're using the C++ Thrift server now and I had a question. 

In the implementation of listen() for TSimpleServer and TThreaderServer: 

try { 
// Start the server listening 
serverTransport_->listen(); 
} catch (TTransportException& ttx) { 
string errStr = string("TThreadedServer::run() listen(): ") +ttx.what(); 
GlobalOutput(errStr.c_str()); 
return; 
} 

This sort of limits our error handling ability :) If for example the port is in use in our development environment we'd like to automatically pick a different port. 

I see that I might be able to specify a function pointer to GlobalOutput although I haven't looked in detail. That just takes a string though. 

Was the intent that packaged server classes be subclassed for error handling? The trouble is that for TSimpleServer and TThreadedServer, everything (including the call to listen()) is inside of serve(). 

Is there another way to do this? 

Thanks, 

Rob