本文整理汇总了C++中QUdpSocket::disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ QUdpSocket::disconnect方法的具体用法?C++ QUdpSocket::disconnect怎么用?C++ QUdpSocket::disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUdpSocket
的用法示例。
在下文中一共展示了QUdpSocket::disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bind
bool ServerPool::bind(QList<QHostAddress> addrs, quint16 port,
bool requireall)
{
m_port = port;
QList<QHostAddress>::const_iterator it;
for (it = addrs.begin(); it != addrs.end(); ++it)
{
QUdpSocket *socket = new QUdpSocket(this);
connect(socket, SIGNAL(readyRead()),
this, SLOT(newUdpDatagram()));
if (socket->bind(*it, port))
{
LOG(VB_GENERAL, LOG_INFO, QString("Binding to UDP %1:%2")
.arg(PRETTYIP(it)).arg(port));
m_udpSockets.append(socket);
}
else if (requireall)
{
LOG(VB_GENERAL, LOG_ERR, QString("Failed binding to UDP %1:%2")
.arg(PRETTYIP(it)).arg(port));
close();
socket->disconnect();
socket->deleteLater();
return false;
}
else
{
LOG(VB_GENERAL, LOG_WARNING, QString("Failed binding to UDP %1:%2")
.arg(PRETTYIP(it)).arg(port));
socket->disconnect();
socket->deleteLater();
}
}
if (m_udpSockets.size() == 0)
return false;
m_listening = true;
return true;
}
示例2: close
void ServerPool::close(void)
{
QTcpServer *server;
while (!m_tcpServers.isEmpty())
{
server = m_tcpServers.takeLast();
server->disconnect();
server->close();
delete server;
}
QUdpSocket *socket;
while (!m_udpSockets.isEmpty())
{
socket = m_udpSockets.takeLast();
socket->disconnect();
socket->close();
delete socket;
}
}
示例3: close
void ServerPool::close(void)
{
QTcpServer *server;
while (!m_tcpServers.isEmpty())
{
server = m_tcpServers.takeLast();
server->disconnect();
server->close();
server->deleteLater();
}
QUdpSocket *socket;
while (!m_udpSockets.isEmpty())
{
socket = m_udpSockets.takeLast();
socket->disconnect();
socket->close();
socket->deleteLater();
}
m_listening = false;
}