コード例 #1
0
ファイル: guimanager.cpp プロジェクト: roymuste/Qt
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
0
ファイル: ipc.cpp プロジェクト: monero-project/monero-core
// 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
0
ファイル: plastiq_debug.cpp プロジェクト: ArtMares/PQEngine
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
0
ファイル: curlftp.cpp プロジェクト: caidongyun/nullfxp
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;
}