Could you show me how the sending side should look like(I can't figure it out)-will it be universal for sending variables such as QStringList and files?
Could you show me how the sending side should look like(I can't figure it out)-will it be universal for sending variables such as QStringList and files?
The point is the same protocol needs to be used on both sides. If I talk to you in Roman Latin and you only understand Polish there is just no way we will understand each other even if we talk about the same things. Both sides need to communicate in the same "language" or at least they have to agree first on languages they understand. If you're using QDataStream on the transmiting side, the receiver has to use QDataStream as well.
I still don't understand why waitforReadyRead doesn't work in slot here with SSL slot, as far as I am concerned when I use it in slot that was onced triggered, for example:
it should make the program to stop and do the while loop until the readyRead signal is emitted and then the program continue its work. It is very strange that the signal doesn't show up here. At the client side I just did clientSocket->write("Confirmation") and it returned 12 bytes written to the socket, but at the server side still nothing. WaitforReadyRead isn't working as it should? And by the way I am from Poland so I could also understand YouQt Code:
while(serverSocket->bytesAvailable() == 0) { }To copy to clipboard, switch view to plain text mode
I think I've finally got it, sorry Wysota for me childish behaviour. I have one question is possible some how to check what kind of data type the QByteArray buffer is carring? I am expecting three types: QStringList, QString,, and the exact date which i will write to the file? I tried using QByteArray::contains("STORAGE"), becouse I know that if it will be QStringList, each QString in that QStringList will have "STORAGE" somewhere. But this is not actually working.
EDIT: when in do contains("S") it sees the single char but only one at time.
Last edited by camol; 17th March 2011 at 13:12.
The data is an opaque blob as far as tcp is concerned. You might have one byte of data or one gigabyte of data there. The only way to detect what data is inside is if you inject such information when sending the data and then you perform a scan to detect such marks on the receiving end.
I thought that it would be as easy as I thought. However, for example if I put some mark at the beginning of the QByteArray which I am sending at the server side, when I get it using client:do I have to cut off the "mark" from the beginning, becouse it will affect for example the file which I will create using this received QByteArray and the file won't be the same as the file from the server side?
You can do whatever you want. The important part is to do the same (or rather "matching") things on both ends of the wire. If you add something to the stream while sending then you have to remove it while receiving.
camol (18th March 2011)
Big thanks
I've encountered a strange problem. I've rewritten my app in the signal-slot way, and everything works like a charm but only at the first time. The server side is louched the client connects, and my outputs from server and client are showing that everytning works like it should but when I connect to the lounched server with client once more, the server some how is sending each files about 2 times, but I can't figure why. I made many new signals for example send_f() which is emitted only when server gets confirmation from client. But as I said after second client louching it looks like this signal is emited twice but it should be impossible considering that first louchning is always perfect. When I fire the client for third time the connection isn't even established.
EDIT:
SOLVED, I was connecting this signal in wrong place. THX WYSOTA for quick reply
Last edited by camol; 24th March 2011 at 14:40.
Most probably you are performing two connect() calls instead of one. Or you have some stale data somewhere in some list.
Bookmarks