Hi Everyone,
I am creating a thrift client in c++
In a class, I declared the:
shared_ptr<TSocket> socket;
shared_ptr<TTransport> transport;
shared_ptr<TPtotocol> protocol;
as private properties..
Later I call a connect method that looks like this
socket = shared_ptr<TSocket>(new TSocket("localhost", 9090));
transport = shared_ptr<TTransport>(new TBufferedTransport(socket));
protocol = shared_ptr<TProtocol>(new TBinaryProtocol(transport));
This works perfectly as long as the server is running.
The thing is, that I need to handle the case when the server is not running..
so for this I have tried
socket = shared_ptr<TSocket>(new TSocket("localhost", 9090));
if(!socket){
//handle here
}
transport = shared_ptr<TTransport>(new TBufferedTransport(socket));
if(!transport){
//handle here
}
protocol = shared_ptr<TProtocol>(new TBinaryProtocol(transport));
if(!protocol){
//handle here
}
I got that from scribe, using a code file that implemented a thrift client, but
it does not work at all.. when the connection is refused, the !socket should
return true for the if, and the handle code should be executed, and it doesn't.
I also tried catching a TException and a default exception... nothing happened..
Any thoughts about how to do this???
Thank you!!!
Diego Guridi Subgerente de Desarrollo | comScore, Inc. (NASDAQ:SCOR)
o +56 2 242 8162 | [email protected]
............................................................................................................................
Certifica is now part of comScore
Measuring the Digital World
Introducing Media Metrix 360, Panel-Centric Digital Audience Measurement
www.comscore.com/MMX360<http://www.comscore.com/MMX360>