Esempio n. 1
0
static bool isDeamonRunning()
{
#if USE_LOCAL_SOCKETS
    QLocalSocket socket;
    socket.connectToServer("gdrdeamon2");
#else
    QTcpSocket socket;
    socket.connectToHost("127.0.0.1", 15002);
#endif
    return socket.waitForConnected(1000);
}
Esempio n. 2
0
static bool sendData(const QByteArray &out, QByteArray *in)
{
#if USE_LOCAL_SOCKETS
    QLocalSocket socket;
    socket.connectToServer("gdrdeamon");
#else
    QTcpSocket socket;
    socket.connectToHost("127.0.0.1", 15001);
#endif
    if (!socket.waitForConnected(1000))
        return false;

    qint32 size = out.size();
    socket.write((char*)&size, sizeof(qint32));
    socket.write(out);
    while (socket.bytesToWrite() && socket.waitForBytesWritten())
        ;

    while (socket.waitForReadyRead())
        in->append(socket.readAll());

    return true;
}