本文整理汇总了C++中QLocalSocket::isOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocalSocket::isOpen方法的具体用法?C++ QLocalSocket::isOpen怎么用?C++ QLocalSocket::isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocalSocket
的用法示例。
在下文中一共展示了QLocalSocket::isOpen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendFortune
void GuiManager::sendFortune()
{
qDebug()<<__FUNCTION__;
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_5_4);
out << (quint16)0;
out << fortunes.at(qrand() % fortunes.size());
out.device()->seek(0);
out << (quint16)(block.size() - sizeof(quint16));
QLocalSocket *clientConnection = server->nextPendingConnection();
qDebug()<<"===================="<<clientConnection->isOpen();
QLocalSocket* socket = clientConnection;
QDataStream in(socket);
in.setVersion(QDataStream::Qt_5_4);
quint16 blockSize = 0;
if (blockSize == 0) {
qDebug()<< (socket->bytesAvailable() < (int)sizeof(quint16));
if (socket->bytesAvailable() < (int)sizeof(quint16))
qDebug()<<"socket->bytesAvailable()"<<socket->bytesAvailable() ;
in >> blockSize;
}
示例2: saveCommand
// Process incoming IPC command. First check if monero-wallet-gui is
// already running. If it is, send it to that instance instead, if not,
// queue the command for later use inside our QML engine. Returns true
// when queued, false if sent to another instance, at which point we can
// kill the current process.
bool IPC::saveCommand(QString cmdString){
qDebug() << QString("saveCommand called: %1").arg(cmdString);
QLocalSocket ls;
QByteArray buffer;
buffer = buffer.append(cmdString);
QString socketFilePath = this->socketFile().filePath();
ls.connectToServer(socketFilePath, QIODevice::WriteOnly);
if(ls.waitForConnected(1000)){
ls.write(buffer);
if (!ls.waitForBytesWritten(1000)){
qDebug() << QString("Could not send command \"%1\" over IPC %2: \"%3\"").arg(cmdString, socketFilePath, ls.errorString());
return false;
}
qDebug() << QString("Sent command \"%1\" over IPC \"%2\"").arg(cmdString, socketFilePath);
return false;
}
if(ls.isOpen())
ls.disconnectFromServer();
// Queue for later
this->SetQueuedCmd(cmdString);
return true;
}
示例3: pqdbg_send_message
void pqdbg_send_message(int lvl, const QString &msg, const QString &title)
{
#ifdef PQDEBUG
static QMutex mutex;
mutex.lock();
QLocalSocket *debugSocket = PHPQt5::debugSocket();
if(debugSocket->isOpen()) {
/*
QByteArray data;
QDataStream out(&data, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_0);
out << reinterpret_cast<quint64>(PQEngine::pqeEngine);
out << PQEngine::pqeCoreName;
out << lvl;
out << title;
out << msg;
out.device()->reset();
// = QString("%1:::%2:::%3:::%4:::%5:::%")
// .arg(reinterpret_cast<quint64>(PQEngine::pqeEngine))
// .arg(PQEngine::pqeCoreName)
// .arg(lvl)
// .arg(title)
// .arg(msg).toUtf8();
debugSocket->write(data);
debugSocket->waitForBytesWritten();
*/
QString str = QString("%1:::%2:::%3:::%4:::%5:::%6:::%")
.arg(reinterpret_cast<quint64>(PQEngine::pqeEngine))
.arg(PQEngine::pqeCoreName)
.arg(reinterpret_cast<quint64>(QThread::currentThread()))
.arg(lvl)
.arg(title)
.arg(msg).toUtf8();
/*
QByteArray block;
QDataStream sendStream(&block, QIODevice::ReadWrite);
sendStream << quint16(0) << str;
sendStream.device()->seek(0);
sendStream << (quint16)(block.size() - sizeof(quint16));
*/
debugSocket->write(str.toUtf8());
debugSocket->waitForBytesWritten();
}
mutex.unlock();
#else
Q_UNUSED(lvl);
Q_UNUSED(msg);
Q_UNUSED(title);
#endif
}
示例4: qDebug
int CurlFtp::closeDataChannel2()
{
QLocalSocket *depSock = this->qdsock2;
qDebug()<<"sock2:"<<depSock<<depSock->isOpen()<<depSock->state();
// this->qdsock2->close();
// delete this->qdsock2;
// this->qdsock2 = NULL;
// this->qdsock2 = NULL;
this->curlWriteDataRouteServer->close();
delete this->curlWriteDataRouteServer;
this->curlWriteDataRouteServer = NULL;
depSock->deleteLater();
// depSock->close();
// delete depSock;
// depSock = NULL;
return 0;
}