本文整理汇总了C++中connection::Ptr::connectionState方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::connectionState方法的具体用法?C++ Ptr::connectionState怎么用?C++ Ptr::connectionState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connection::Ptr
的用法示例。
在下文中一共展示了Ptr::connectionState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connectTo
bool UTPSocket::connectTo(const net::Address& addr)
{
if (!bt::Globals::instance().isUTPEnabled())
return false;
UTPServer & srv = bt::Globals::instance().getUTPServer();
reset();
conn = srv.connectTo(addr);
Connection::Ptr ptr = conn.toStrongRef();
if (!ptr)
return false;
m_state = CONNECTING;
ptr->setBlocking(blocking);
if (blocking)
{
bool ret = ptr->waitUntilConnected();
if (ret)
m_state = CONNECTED;
return ret;
}
return ptr->connectionState() == CS_CONNECTED;
}
示例2: ready
bool UTPSocket::ready(const net::Poll* p, net::Poll::Mode mode) const
{
Q_UNUSED(p);
Connection::Ptr ptr = conn.toStrongRef();
if (!ptr)
return false;
if (mode == net::Poll::OUTPUT)
{
if (polled_for_writing)
{
polled_for_writing = false;
return ptr->isWriteable();
}
}
else
{
if (polled_for_reading)
{
polled_for_reading = false;
return bytesAvailable() > 0 || ptr->connectionState() == CS_CLOSED;
}
}
return false;
}
示例3: recv
int UTPSocket::recv(bt::Uint8* buf, int max_len)
{
Connection::Ptr ptr = conn.toStrongRef();
if (!ptr || ptr->connectionState() == CS_CLOSED)
return 0;
try
{
if (ptr->bytesAvailable() == 0)
{
if (blocking)
{
if (ptr->waitForData())
return ptr->recv(buf, max_len);
else
return 0; // connection should be closed now
}
else
return -1; // No data ready and not blocking so return -1
}
else
return ptr->recv(buf, max_len);
}
catch (Connection::TransmissionError & err)
{
close();
return -1;
}
}
示例4: connectSuccesFull
bool UTPSocket::connectSuccesFull()
{
Connection::Ptr ptr = conn.toStrongRef();
if (ptr && ptr->connectionState() == CS_CONNECTED)
{
setRemoteAddress(ptr->remoteAddress());
m_state = CONNECTED;
return true;
}
else
return false;
}
示例5: prepare
void UTPSocket::prepare(net::Poll* p, net::Poll::Mode mode)
{
Connection::Ptr ptr = conn.toStrongRef();
if (ptr && ptr->connectionState() != CS_CLOSED)
{
UTPServer & srv = bt::Globals::instance().getUTPServer();
srv.preparePolling(p, mode, ptr);
if (mode == net::Poll::OUTPUT)
polled_for_writing = true;
else
polled_for_reading = true;
}
}
示例6: ok
bool UTPSocket::ok() const
{
Connection::Ptr ptr = conn.toStrongRef();
return ptr && ptr->connectionState() != CS_CLOSED;
}