Bonjour, je souhaiterais votre aide au sujet de la réception de données sous qt en tcp/ip.
Sous C#, j'envoie :
Sous qt, je ne vois pas comment recevoir ces données.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 byte[] outStream = System.Text.Encoding.ASCII.GetBytes("Hello my friend$"); serverStream.Write(outStream, 0, outStream.Length);
j'ai trouvé cela mais je n'arrive pas à bien l'exploiter. pourriez vous me donner un indice merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 QDataStream in(tcpSocket); in.setVersion(QDataStream::Qt_4_0); if (blockSize == 0) { if (tcpSocket->bytesAvailable() < (int)sizeof(quint16)) return; in >> blockSize; } if (tcpSocket->bytesAvailable() < blockSize) return; QByteArray nextData; in >> nextData; if (nextData == currentData) { QTimer::singleShot(0, this, SLOT(requestNewData())); return; } currentData = nextData;
Partager