说明
Thrift服务器端采用的是Boost库的智能指针保存客户端的连接对象,因此当创建的服务线程正常退出的时候,对象会自动销毁,不需要手动调用任何的销毁函数
void TSocket::close() {
if (socket_ != -1) {
#ifdef _WIN32
shutdown(socket_, SD_BOTH);
::closesocket(socket_);
#else
shutdown(socket_, SHUT_RDWR);
::close(socket_);
#endif
}
socket_ = -1;
}
客户端连接的套接字在这里进行了关闭
/**
* Wraps a transport into a buffered one.
*
*/
class TBufferedTransportFactory : public TTransportFactory {
public:
TBufferedTransportFactory() {}
virtual ~TBufferedTransportFactory() {}
/**
* Wraps the transport into a buffered one.
*/
virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) {
return boost::shared_ptr<TTransport>(new TBufferedTransport(trans));
}
};