本文整理汇总了C++中ConnectionPtr::Connect方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::Connect方法的具体用法?C++ ConnectionPtr::Connect怎么用?C++ ConnectionPtr::Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionPtr
的用法示例。
在下文中一共展示了ConnectionPtr::Connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Connect
int PeerNode::Connect()
{
int result = 0;
boost::recursive_mutex::scoped_lock L(m_mutex);
// if already connected then return
if( m_bConnected == true )
return 0;
// else connects
// makes connection via connection manager interface
ConnectionManagerPtr pConnMgr = ConnectionManager::GetConnectionManager();
ConnectionPtr pConn = m_pConn;
if(pConn == NULL) {
pConn = pConnMgr->Connect(m_ipAddress, m_listenPort);
if( pConn == NULL ) {
Log(ERR, L"Could not make connection to Peer Node with ip - %s, port - %d\n", m_ipAddress, m_port);
if( this->IsCoordinatorNode() ) {
// try connecting to backups
pConn = ConnectBackups();
}
if( pConn == NULL ) {
return -1;
}
}
} else {
pConn->Connect(m_ipAddress, m_listenPort);
}
//m_pConn.reset();
m_pConn = pConn;
m_pConn->SetPeerNode(shared_from_this());
m_pConn->Start();
m_bConnected = true;
return result;
}