|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// _pIOClient is a QIODevice* object wrapping the client's socket
qint64 n64, m64;
QByteArray bytes;
QTcpSocket sckt;
// connect sckt to another server
sckt.connectToHost(...);
// ...
_pIOClient->write("test 1");
// ask the server to start the streaming
sckt.write("PLAY ...");
// ...
_pIOClient->write("test 2");
while (_pIOClient->isOpen()) {
if (sckt.waitForReadyRead(3000)) {
bytes = sckt.readAll();
m64 = bytes.size();
qDebug("%ld bytes to write", m64);
if (m64!=0) {
n64 = _pIOClient->write(bytes.data(), m64);
qDebug("written %ld of %ld bytes", n64, m64);
}
}
}
|
[/list=1]
Quoted
1296 bytes to write
written 1296 of 0 bytes
4 bytes to write
written 4 of 0 bytes
1296 bytes to write
written 1296 of 0 bytes
4 bytes to write
written 4 of 0 bytes
...
ocketError ) for the client's socket This post has been edited 4 times, last edit by "Nicolas SOUCHON" (May 6th 2008, 3:05pm)
Quoted
I don't know about #1 but for #2 the reason the application thinks that _pIOClient is always opened is because I don't see where you close it
Quoted
how and where is your loop implemented?
seems me your loop is blocking
Quoted
better than waitForReadyRead would be to use
- the signal QIODevice::readyRead() for the camera's device
- the signal QAbstractSocket::error( QAbstractSocket:ocketError ) for the client's socket