本文整理汇总了C++中Transport::open方法的典型用法代码示例。如果您正苦于以下问题:C++ Transport::open方法的具体用法?C++ Transport::open怎么用?C++ Transport::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transport
的用法示例。
在下文中一共展示了Transport::open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UDTsend
int CGMP::UDTsend(const char* ip, const int& port, CGMPMessage* msg)
{
Transport t;
if (t.open(m_iUDTReusePort, false, true) < 0)
return -1;
if (t.connect(ip, port) < 0)
{
t.close();
return -1;
}
if ((t.send((char*)(&m_iPort), 4) < 0) || (t.send((char*)(msg->m_piHeader), 16) < 0) || (t.send((char*)&(msg->m_iLength), 4) < 0))
{
t.close();
return -1;
}
if (t.send(msg->m_pcData, msg->m_iLength) < 0)
{
t.close();
return -1;
}
t.close();
return 16 + msg->m_iLength;
}
示例2: connect
/**
* Connects to the gdbserver.
*
* @return A NaviError code that indicates whether the operation succeeded or
not.
*/
NaviError connect() {
return transport->open();
}
示例3: connect
int DataChn::connect(const string& ip, int port)
{
// no need to connect to self
if ((ip == m_strIP) && (port == m_iPort))
return 1;
Address addr;
addr.m_strIP = ip;
addr.m_iPort = port;
pthread_mutex_lock(&m_ChnLock);
map<Address, ChnInfo*, AddrComp>::iterator i = m_mChannel.find(addr);
if (i != m_mChannel.end())
{
if ((NULL != i->second->m_pTrans) && i->second->m_pTrans->isConnected())
{
pthread_mutex_unlock(&m_ChnLock);
return 0;
}
delete i->second->m_pTrans;
i->second->m_pTrans = NULL;
}
ChnInfo* c = NULL;
if (i == m_mChannel.end())
{
c = new ChnInfo;
c->m_pTrans = NULL;
pthread_mutex_init(&c->m_SndLock, NULL);
pthread_mutex_init(&c->m_RcvLock, NULL);
pthread_mutex_init(&c->m_QueueLock, NULL);
m_mChannel[addr] = c;
}
else
{
c = i->second;
}
pthread_mutex_unlock(&m_ChnLock);
pthread_mutex_lock(&c->m_SndLock);
if ((NULL != c->m_pTrans) && c->m_pTrans->isConnected())
{
c->m_iCount ++;
pthread_mutex_unlock(&c->m_SndLock);
return 0;
}
Transport* t = new Transport;
t->open(m_iPort, true, true);
int r = t->connect(ip.c_str(), port);
if (NULL == c->m_pTrans)
c->m_pTrans = t;
else
{
Transport* tmp = c->m_pTrans;
c->m_pTrans = t;
delete tmp;
}
pthread_mutex_unlock(&c->m_SndLock);
return r;
}