Hi..
I want simple tcpClient tcpServer communcation example.
I have read fortuneClient & fortuneServer but have found it difficult to understand.
Is their any simple example.
Pls help..
Hi..
I want simple tcpClient tcpServer communcation example.
I have read fortuneClient & fortuneServer but have found it difficult to understand.
Is their any simple example.
Pls help..
What part is difficult to understand?
I don't know what to add to these examples.
sending the data & recieving it is little difficult.
Can u explain it?
Sending data:
Assume you already have a socket established.
Then sending on the socket is just as in the example:
Qt Code:
QByteArray block; clientConnection->write(block);To copy to clipboard, switch view to plain text mode
You need a byte array. You define a Datastream based on the byte array.
You feed the byte array with data and when finished you just write it to the socket.
Thats how you send data.
Receiving data is that you react on the signal bytesAvailable() of the socket.
You get again a datastream. It is now similar to sending data.
But for this one it is important to understand that the signal just tells that some data has arrived, not that all data has arrived.
It is your job to check if everything is already there what you need. That's why in the Fortune example the first thing transmitted is the length of your packet (which I have removed in above example).
Any futher hint needed?
Bookmarks