0
我有一个小的代码片段,使用Thrift进行网络通信。是否boost :: shared_ptr <TTransport>关闭连接一旦被销毁?
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;
}
}
}
我的问题是:boost :: shared_ptr关闭连接一旦被破坏?如果是,那么transport->close();
可以被注释掉没有任何问题,对吧?
是的,我刚才看了一下源代码并找到了相同的东西。谢谢! –