I have a small code snippet that uses Thrift for network communications.
int main() {
while (true) {
boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
CalculatorClient client(protocol);
try {
transport->open();
client.ping();
cout << "ping()" << endl;
// following line is commented out intentionally
//transport->close();
} catch (TException& tx) {
cout << "ERROR: " << tx.what() << endl;
}
}
}
My question is: Does boost::shared_ptr close connection once destroyed? If yes, then transport->close();
can be commented out without any problems, right?