Make the reads blocking. We'll put those in a thread.
It'll be much easier to maintaining the upcoming code. svn path=/branches/work/~ervin/sodep/; revision=923377
This commit is contained in:
parent
ac708dc8d3
commit
01f11ad43b
@ -125,6 +125,10 @@ inline void sodepWrite(QIODevice &io, const SodepMessage &message)
|
||||
|
||||
inline double sodepReadDouble(QIODevice &io)
|
||||
{
|
||||
while (io.bytesAvailable()<8) {
|
||||
io.waitForReadyRead(-1);
|
||||
}
|
||||
|
||||
double d;
|
||||
char *out = (char*)&d;
|
||||
char in[8];
|
||||
@ -140,6 +144,10 @@ inline double sodepReadDouble(QIODevice &io)
|
||||
|
||||
inline qint32 sodepReadInt32(QIODevice &io)
|
||||
{
|
||||
while (io.bytesAvailable()<4) {
|
||||
io.waitForReadyRead(-1);
|
||||
}
|
||||
|
||||
qint32 i;
|
||||
char *out = (char*)&i;
|
||||
char in[4];
|
||||
@ -155,6 +163,10 @@ inline qint32 sodepReadInt32(QIODevice &io)
|
||||
|
||||
inline qint64 sodepReadInt64(QIODevice &io)
|
||||
{
|
||||
while (io.bytesAvailable()<8) {
|
||||
io.waitForReadyRead(-1);
|
||||
}
|
||||
|
||||
qint64 i;
|
||||
char *out = (char*)&i;
|
||||
char in[8];
|
||||
@ -172,6 +184,10 @@ inline QString sodepReadString(QIODevice &io)
|
||||
{
|
||||
qint32 length = sodepReadInt32(io);
|
||||
|
||||
while (io.bytesAvailable()<length) {
|
||||
io.waitForReadyRead(-1);
|
||||
}
|
||||
|
||||
char *data = new char[length+1];
|
||||
io.read(data, length);
|
||||
data[length] = '\0';
|
||||
@ -186,6 +202,10 @@ inline SodepValue sodepReadValue(QIODevice &io)
|
||||
{
|
||||
SodepValue result;
|
||||
|
||||
while (io.bytesAvailable()<1) {
|
||||
io.waitForReadyRead(-1);
|
||||
}
|
||||
|
||||
char code;
|
||||
io.getChar(&code);
|
||||
|
||||
@ -225,6 +245,10 @@ inline SodepValue sodepReadValue(QIODevice &io)
|
||||
|
||||
inline SodepFault sodepReadFault(QIODevice &io)
|
||||
{
|
||||
while (io.bytesAvailable()<1) {
|
||||
io.waitForReadyRead(-1);
|
||||
}
|
||||
|
||||
char code;
|
||||
io.getChar(&code);
|
||||
|
||||
|
@ -112,9 +112,6 @@ private slots:
|
||||
message.setData(value);
|
||||
sodepWrite(m_socket, message);
|
||||
|
||||
QVERIFY(m_socket.waitForReadyRead(5000));
|
||||
QTest::qWait(1000);
|
||||
|
||||
SodepMessage reply = sodepReadMessage(m_socket);
|
||||
|
||||
m_socket.close();
|
||||
@ -134,9 +131,6 @@ private slots:
|
||||
SodepMessage message("/", "getServices");
|
||||
sodepWrite(m_socket, message);
|
||||
|
||||
QVERIFY(m_socket.waitForReadyRead(5000));
|
||||
QTest::qWait(1000);
|
||||
|
||||
SodepMessage reply = sodepReadMessage(m_socket);
|
||||
|
||||
m_socket.close();
|
||||
@ -183,9 +177,6 @@ private slots:
|
||||
message.setData(data);
|
||||
sodepWrite(m_socket, message);
|
||||
|
||||
QVERIFY(m_socket.waitForReadyRead(5000));
|
||||
QTest::qWait(1000);
|
||||
|
||||
SodepMessage reply = sodepReadMessage(m_socket);
|
||||
|
||||
m_socket.close();
|
||||
@ -217,9 +208,6 @@ private slots:
|
||||
message.setData(value);
|
||||
sodepWrite(m_socket, message);
|
||||
|
||||
QVERIFY(m_socket.waitForReadyRead(5000));
|
||||
QTest::qWait(1000);
|
||||
|
||||
SodepMessage reply = sodepReadMessage(m_socket);
|
||||
|
||||
m_socket.close();
|
||||
|
Loading…
Reference in New Issue
Block a user