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();
可以被註釋掉沒有任何問題,對吧?
是的,我剛纔看了一下源代碼並找到了相同的東西。謝謝! –