-
4 Attachment(s)
QSslSocket vs QTcpSocket problem
Modified server1 code:
Modified test server2/client code: (removed)
I'm having trouble uploading through using SSL, a situation that in early server1 sends some 8842 bytes, and the server gives a two bytesAvaible just exactly what 4096 means that the code can not go further in the next step bytesavaible gives some 4,044 bytes, and therefore all dishes are made from the second turn, do-while loop. Previously, I managed to write a version without SSL (which is, however, I needed) and everything worked perfectly as I wanted to send no matter whether large or small files and in different quantities. Servera1 without ssl code:
(removed)
server2/client without SSL:
(removed)
I've changed in server2 signal readyRead to encrypted in connect, becouse it was my mistake, but after that I can't get out from first loop becouse bytesAvailable gives 0 bytes and I don't know. Thanks for the help in advance.
-
Re: QSslSocket vs QTcpSocket problem
Sorry I can't find the EDIT option to edit my first post:
Code:
{
{
}
}
void DServer::incomingConnection(int socketDescriptor)
{
serverSocket = new QSslSocket(this);
if (serverSocket->setSocketDescriptor(socketDescriptor))
{
connect(serverSocket, SIGNAL(encrypted()), this, SLOT(response_to_connection()));
connect(serverSocket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(errorOccured(const QList<QSslError> &)));
connect(serverSocket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
serverSocket->setProtocol(QSsl::SslV3);
serverSocket->setPrivateKey("server.key");
serverSocket->setLocalCertificate("server.crt");
serverSocket->startServerEncryption();
}
else
{
delete serverSocket;
}
}
void DServer::response_to_connection()
{
if(connected_host.
toString() == QString("192.168.56.101")) {
response_to_replication();
}
}
void DServer::errorOccured(const QList<QSslError> &error)
{
serverSocket->ignoreSslErrors();
}
void DServer::response_to_replication()
{
blockSize = 0;
block.clear();
serverfiles.clear();
serverfiles = rfilelist();
out << (quint64)0;
out << (out,serverfiles);
out.device()->seek(0);
out << (quint64)(block.size() - sizeof(quint64));
qint64 data = serverSocket->write(block);
QTextStream(stdout) <<
"block.size = " <<block.
size() <<endl;
serverSocket->reset();
if (blockSize == 0)
{
do
{
{
return;
}
serverSocket->waitForReadyRead(1);
}
while(serverSocket->bytesAvailable() < (int)sizeof(quint64));
in >> blockSize;
}
do
{
{
return;
}
serverSocket->waitForReadyRead(1);
}
while(serverSocket->bytesAvailable() < blockSize);
in >> (in,requestedFL);
serverSocket->reset();
for(int h=0;h<requestedFL.count();h++)
{
}
if(requestedFL.isEmpty() == false)
{
int len_requestedFL = requestedFL.count();
for(int i=0; i<len_requestedFL; i++)
{
block.clear();
ba.clear();
compressed_ba.clear();
QFile file(*homepath
+ requestedFL
[i
]);
return;
ba = file.readAll();
out << (quint64)0;
out << ba;
out.device()->seek(0);
out << (quint64)(block.size() - sizeof(quint64));
serverSocket->write(block);
serverSocket->reset();
file.close();
blockSize = 0;
int v=0;
do
{
{
return;
}
serverSocket->waitForReadyRead(1);
}
while((serverSocket->bytesAvailable() < (int)sizeof(quint64)) );
in >> blockSize;
in >> confirmation;
serverSocket->reset();
}
}
}
void DServer::clientDisconnected()
{
if (!serverSocket)
return;
serverSocket->deleteLater();
wtolog
(QString("Client Disconnected from Server"));
}
void DServer::response_to_connection()
{
while (hasPendingConnections())
{
QSslSocket *client = nextPendingConnection();
connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
serverSockets.append(client);
if(connected_host.
toString() == QString("192.168.56.101")) {
response_to_replication(client);
}
}
}
server2client:
Code:
Server::Server()
{
clientSocket = new QSslSocket(this);
clientSocket->abort();
quint16 hostPort = 55678;
connect(clientSocket, SIGNAL(readyRead()),this, SLOT(connectionEstablished()));
connect(clientSocket, SIGNAL(sslErrors(const QList<QSslError> &)),this, SLOT(errorOccured(const QList<QSslError> &)));
clientSocket->setProtocol(QSsl::SslV3);
clientSocket->connectToHostEncrypted(hostIP, hostPort);
}
void Server::connectionEstablished()
{
QSslCertificate cert = clientSocket->peerCertificate();
if(cert.isNull())
{
}
QSslCipher cipher;
cipher = clientSocket->sessionCipher();
initiate_replication();
}
void Server::initiate_replication()
{
blockSize = 0;
if (blockSize == 0)
{
do
{
clientSocket->waitForReadyRead(1);
}
while(clientSocket->bytesAvailable() < (int)sizeof(quint64));
in >> blockSize;
}
do
{
clientSocket->waitForReadyRead(1);
}
while(clientSocket->bytesAvailable() < blockSize);
in >> (in,receivedFL);
clientSocket->reset();
block.clear();
out << (quint64)0;
out << (out,requestedlist);
out.device()->seek(0);
out << (quint64)(block.size() - sizeof(quint64));
clientSocket->write(block);
clientSocket->reset();
blockSize = 0;
if (blockSize == 0)
{
do
{
clientSocket->waitForReadyRead(1);
}
while(clientSocket->bytesAvailable() < (int)sizeof(quint64));
in >> blockSize;
}
int p=0;
do
{
clientSocket->waitForReadyRead(1000);
}
while (clientSocket->bytesAvailable() < blockSize);
ba = clientSocket->readAll();
clientSocket->reset();
block.clear();
out << requestedlist[j];
out.device()->seek(0);
out << (quint64)(block.size() - sizeof(quint64));
clientSocket->write(block);
clientSocket->reset();
}
clientSocket->disconnectFromHost();
}
void Server::errorOccured(const QList<QSslError> &error)
{
clientSocket->ignoreSslErrors();
}
Server::~Server()
{
}
-
Re: QSslSocket vs QTcpSocket problem
What is this supposed to do?
Code:
ba = clientSocket->readAll();
clientSocket->reset();
Instead of using waitForReadyRead() you should really use signals and slots.
-
Re: QSslSocket vs QTcpSocket problem
When I will get it to work I am going to improve the code in the estetic way but now I really must to get it work.
This element doesn't matter at this moment as I wrote that before without SSL everything work great and like I wanted it to work but now I don't know why i teh first loop I get clientSocket->bytesAvailable = 0 in the first loop in client. The signal encrypted was emitted becouse the program went in the function initiate_replication, the server1 gives the exact amount of bytes that was written in to the socket but at the client side there is nothing to receive that is what bothers me, that why I can't move on with it. Please help.
-
Re: QSslSocket vs QTcpSocket problem
Let's try code from Secure Socket Client From QT examples. It's work nice.
And also as Mr. Wysota say you should use signal slot mechanism, or use processEvent() in loops
-
Re: QSslSocket vs QTcpSocket problem
But I tried to use this http://xizhizhu.blogspot.com/2010/08...unication.html
I compiled those codes and they worked fine then I transfered the vital elements to my project and didn't get the positive result like with the original ones.
-
Re: QSslSocket vs QTcpSocket problem
Quote:
Originally Posted by
camol
When I will get it to work I am going to improve the code in the estetic way but now I really must to get it work.
This element doesn't matter at this moment as I wrote that before without SSL everything work great and like I wanted it to work but now I don't know why i teh first loop I get clientSocket->bytesAvailable = 0 in the first loop in client. The signal encrypted was emitted becouse the program went in the function initiate_replication, the server1 gives the exact amount of bytes that was written in to the socket but at the client side there is nothing to receive that is what bothers me, that why I can't move on with it. Please help.
Your problem is generally the fact that the iodevice has a limited read buffer and your block is larger than it. The approach you are using is generally incorrect, you should be reading the data into your own buffer and only then check the size of your buffer against the size of data you expect.
Either like so:
Code:
while(buffer.size() < blockSize) {
socket->waitForReadyRead();
buffer.append(socket->readAll());
}
doSomethingWith(buffer);
or (better) like so:
Code:
void X::onSocketReadyRead(){
m_buffer.append(socket->readAll());
while(m_buffer.size()>=blockSize) processData();
}
-
Re: QSslSocket vs QTcpSocket problem
I am very greatfull for your help and interest I will give it a try and change my aproach to the problem. Hope it will work, I will response with the results.
EDIT:
But still I have a question why this mechanism which I used in those attachments with "normal" in name works, becouse you wrote that is bad approach but those"normal" verions of my codes work as they should???
-
Re: QSslSocket vs QTcpSocket problem
Hmm but i think that I do exactly the same you wrote just in a bit diffrent way but idea is the same, firstly the server writes to the socket using QDataStream out, which uses the QByteArray block. Data is written to the block and the the size of the this block is being put at the beginning of the QDataStream. Then at the client side the first do-while loop waits for "the size" of the expected data(for example: files) the size of "the size" is known thats why this is in the first while: clientSocket->bytesAvailable() < (int)sizeof(quint64). After I get the size of the expected incoming data(for example file) thanks to the blockSize now I can wait for my exact data using second do-while loop, and that is why I am using this: clientSocket->bytesAvailable() < blockSize. This is the mechanism that I'm using here and it really worked great, even in sending 10 MB in one file, and as I remember I've used the example from Qt examples and modified it (mostly changed If-instructions to do-while to get to work with big files). After adding SSL something went wrong and it's strange, becouse I read that I can use QSslSockets like QTcpSockets after reimplementing incomingconnection signal. I think that whole handshake stuff is ok becouse I've checked states of both socket server and client side and they were in right state and were encrypted.
-
Re: QSslSocket vs QTcpSocket problem
Quote:
Originally Posted by
camol
Hmm but i think that I do exactly the same you wrote just in a bit diffrent way but idea is the same, firstly the server writes to the socket using
QDataStream out, which uses the
QByteArray block. Data is written to the block and the the size of the this block is being put at the beginning of the
QDataStream. Then at the client side the first do-while loop waits for "the size" of the expected data(for example: files) the size of "the size" is known thats why this is in the first while: clientSocket->bytesAvailable() < (int)sizeof(quint64). After I get the size of the expected incoming data(for example file) thanks to the blockSize now I can wait for my exact data using second do-while loop, and that is why I am using this: clientSocket->bytesAvailable() < blockSize. This is the mechanism that I'm using here and it really worked great, even in sending 10 MB in one file, and as I remember I've used the example from Qt examples and modified it (mostly changed If-instructions to do-while to get to work with big files). After adding SSL something went wrong and it's strange, becouse I read that I can use
QSslSockets like
QTcpSockets after reimplementing incomingconnection signal. I think that whole handshake stuff is ok becouse I've checked states of both socket server and client side and they were in right state and were encrypted.
This mechanism is invalid in a general case. Buffers are limited and when they are full, data stops coming in and you'll never reach your desired block count. With plain TCP socket it worked because it had a larger buffer than the SSL socket that apparently has it set at 4kB. Again, this approach is INVALID. I know it has been used in many places in people's code and I think it originates from one of Qt books but it doesn't change the fact that it is invalid and also makes your application prone to DOS attacks.
-
Re: QSslSocket vs QTcpSocket problem
But still there is one "?" for me becouse I can't get even 20bytes through this socket. The server writes 20bytes(return value of byteswritten) to the socket,it's a test QString message, but I still can't get anything at the client side. The capacity of the SslSocket is so small the? I need to get those first bytes of the socket to be aware of expected amount of date and use your code aproach.
-
Re: QSslSocket vs QTcpSocket problem
Is encryption successfully established?
-
Re: QSslSocket vs QTcpSocket problem
Yes I've checked at both sides isEncrypted and I get true for them.
-
Re: QSslSocket vs QTcpSocket problem
And communication works one way or you can't read any data on both ends?
-
Re: QSslSocket vs QTcpSocket problem
I haven't checked this way client->server yet, becouse my idea was this way first server->client. I've also checked the return value at server side of bytesWritten(sth. like that) was the same as block.size, so I it looks like the data were written to the using socket but the client doesn't receive anything.
-
Re: QSslSocket vs QTcpSocket problem
How do you check that you receive no data?
-
Re: QSslSocket vs QTcpSocket problem
I use socket->bytesAvailable I get 0 all the time. Now ,as I sad, I try to send small amount of date(test QString) that has about 20bytes so I think it shouldn't be too much, but still I'm at the same point when I was trying to send the exact date before.
-
Re: QSslSocket vs QTcpSocket problem
Quote:
Originally Posted by
camol
I use socket->bytesAvailable I get 0 all the time.
Ok, but WHEN do you do that?
-
Re: QSslSocket vs QTcpSocket problem
Here
Code:
void Server::initiate_replication()
{
blockSize = 0;
if (blockSize == 0)
{
do
{
qDebug << clientSocket->bytesAvailable();
clientSocket->waitForReadyRead(1);
}
while(clientSocket->bytesAvailable() < (int)sizeof(quint64));
in >> blockSize;
}
after the signal encrypted is emitted.
-
Re: QSslSocket vs QTcpSocket problem
I'd say that's way too early. Anyway I suggest you rewrite your code to use signals and slots. You wouldn't have any of those problems then.
-
Re: QSslSocket vs QTcpSocket problem
Now I see the point and I am slowly moving to the idea you presented. But I have a problem constructing the while loop which is suppose to get the size of the next incoming data I tried this but I know that fails:
Code:
void Server::onreadyRead()
{
while(buffer.size() < (int)sizeof(quint64))
{
clientSocket->waitForReadyRead(1);
blockSizee.append(clientSocket->readAll());
}
}
TEST:
The byte size of the "size information", sended by server, is about 8kB but after first readyRead signal client gets first 4kB, and after second signal buffer meets the while condition and skips it, and I can't get the full right size.
-
Re: QSslSocket vs QTcpSocket problem
You don't need such while loops.
Code:
void Server::onReadyRead(){
buffer.append(socket->readAll());
while(buffer.size() >=4) {
uint32 blockSize = buffer.at(0) << 24 | buffer.at(1) << 16 | buffer.at(2) << 8 | buffer.at(3); // or similar, e.g. qFromBigEndian
if(buffer.size()>=4+blockSize){
buffer = buffer.mid(4+blockSize);
processData(data);
} else return;
}
}
-
Re: QSslSocket vs QTcpSocket problem
Quote:
Originally Posted by
wysota
You don't need such while loops.
Code:
void Server::onReadyRead(){
buffer.append(socket->readAll());
while(buffer.size() >=4) {
uint32 blockSize = buffer.at(0) << 24 | buffer.at(1) << 16 | buffer.at(2) << 8 | buffer.at(3); // or similar, e.g. qFromBigEndian
if(buffer.size()>=4+blockSize){
buffer = buffer.mid(4+blockSize);
processData(data);
}
}
}
why you use while(buffer.size() >=4)? I mean for what "4" stands here for?
-
Re: QSslSocket vs QTcpSocket problem
4 stands for sizeof(quint32).
Actually my code had a bug, it was missing an "else" statement. I just corrected it.
-
Re: QSslSocket vs QTcpSocket problem
Code:
void Server::onReadyRead()
{
if(data == Size_of_Data)
{
QTextStream(stdout) <<
" Entering the slot = "<<a
++ <<endl;
buffer.append(clientSocket->readAll());
while(buffer.size() >=4)
{
quint32 blockSize = buffer.at(0) << 24 | buffer.at(1) << 16 | buffer.at(2) << 8 | buffer.at(3); // or similar, e.g. qFromBigEndian
QTextStream(stdout) <<
" before IF buffer = "<<buffer.
size() <<endl;
QTextStream(stdout) <<
" before IF blockSize = "<<sizeof
(blockSize
)<<endl;
if(buffer.size()>=4+blockSize)
{
buffer = buffer.mid(4+blockSize);
QTextStream(stdout) <<
" in IF data = "<<data.
size() <<endl;
QTextStream(stdout) <<
" in IF buffer = "<<buffer.
size() <<endl;
//processData(data);
}
else
{
QTextStream(stdout) <<
" on output buffer.size = "<<buffer.
size() <<endl;
return;
}
}
}
else if(data == Exact_Data)
{
}
}
I wrote sth like this, but i don't know exactle when I should pull out the right buffer.size out of the slot (to use it for expecting the incomimg file data)becouse, I've run a simple test and got:
Code:
Entering the slot = 0
in while = 0
before IF buffer = 4096
before IF blockSize = 4
entering IF = 0
in IF data = 0
in IF buffer = 4092
in while = 1
before IF buffer = 4092
before IF blockSize = 4
on output buffer.size = 4092
Entering the slot = 1
in while = 2
before IF buffer = 8188
before IF blockSize = 4
on output buffer.size = 8188
Entering the slot = 2
in while = 3
before IF buffer = 8848
before IF blockSize = 4
on output buffer.size = 8848
-
Re: QSslSocket vs QTcpSocket problem
Lines #3 and #18 suggest you have two variables called "data" where one shadows the other. What's the purpose of if in #3 anyway?
-
Re: QSslSocket vs QTcpSocket problem
But one is global the first one and the second one is local for the method, I've changed the first "data" to in_data but it doesn't has any influence. The in_data is an enum type, which I've created, becouse I thought slot onReadyRead always starts after signal readyRead so in_data informs that the incoming data is no longer the size of the file, but exactly the expected file.
EDIT:
When I'm sending a bigger file and I try get the size of it, the result of my test is a bit different:
Code:
Entering the slot = 0
in while = 0
before IF buffer = 4096
before IF blockSize = 4
entering IF = 0
in IF data = 0
in IF buffer = 4092
in while = 1
before IF buffer = 4092
before IF blockSize = 4
on output buffer.size = 4092
Entering the slot = 1
in while = 2
before IF buffer = 8188
before IF blockSize = 4
on output buffer.size = 8188
Entering the slot = 2
in while = 3
before IF buffer = 12284
before IF blockSize = 4
on output buffer.size = 12284
Entering the slot = 3
in while = 4
before IF buffer = 16380
before IF blockSize = 4
on output buffer.size = 16380
Entering the slot = 4
in while = 5
before IF buffer = 17688
before IF blockSize = 4
entering IF = 1
in IF data = 17684
in IF buffer = 0
Becouse my "test" ends in IF instruction now.
Another EDIT:
I've changed "4" in your code to "8" and now it stands for quint64 and everything looks like in the first example.
-
Re: QSslSocket vs QTcpSocket problem
I still don't understand what the if is for. Anyway, sizeof(blockSize) will always return 4 (it's a 32 bit integer, after all) so I don't understand why you're checking it. Just to make sure - does the sending side encode the block size the same way the receiving size decodes it?
-
Re: QSslSocket vs QTcpSocket problem
I'm sending it like this:
Code:
void DServer::response_to_replication()
{
QTextStream(stdout) <<
"wszedlem do RESPONSE_TO_REPLICATION" <<endl;
/********************************************************************/
/*SENDING LIST WITH STORED FILES TO SERVER WHICH ESTABLISHED CONNECTION*/
/********************************************************************/
blockSize = 0;
block.clear();
serverfiles.clear();
serverfiles = rfilelist();
out << (quint64)0;
out << (out,serverfiles);
out.device()->seek(0);
out << (quint64)(block.size() - sizeof(quint64));
}
the IF-thing: becouse date are coming to the client and when they are ready to read at client side the signal readyRead is emitted which is connected to one single slot called onReadyRead, so when I get the incoming data and interpretate them as the information about the size which was sent by server side of the connection. The signal readyRead will be still emited becouse now client will be receiving the exact data, and the onReadyRead slot will be triggered, so I want to prevent by using this IF-thing to prevent this slot from behaving as it is receiving size when it is already receving the exact expected data.
-
Re: QSslSocket vs QTcpSocket problem
Quote:
Originally Posted by
camol
I'm sending it like this:
This won't work, obviously. The receiving end expects something completely different.
Quote:
the IF-thing: becouse date are coming to the client and when they are ready to read at client side the signal readyRead is emitted which is connected to one single slot called onReadyRead, so when I get the incoming data and interpretate them as the information about the size which was sent by server side of the connection. The signal readyRead will be still emited becouse now client will be receiving the exact data, and the onReadyRead slot will be triggered, so I want to prevent by using this IF-thing to prevent this slot from behaving as it is receiving size when it is already receving the exact expected data.
Why do you want to prevent it? I think you don't understand the code I gave you. The slot is meant to fire each time new data arrives into the socket. Without any exceptions or special conditions. Otherwise you'll just lifelock your application.
-
Re: QSslSocket vs QTcpSocket problem
But you wrote sth like this :
Quote:
Originally Posted by
wysota
Either like so:
Code:
while(buffer.size() < blockSize) {
socket->waitForReadyRead();
buffer.append(socket->readAll());
}
doSomethingWith(buffer);
[/code]
and I thought that this refers to receiving exact data data, and this blockSize I will get by this last code which I've posted thanks to you.
-
Re: QSslSocket vs QTcpSocket problem
I don't see how this code snippet is related to what I have just said :)
-
Re: QSslSocket vs QTcpSocket problem
:o sorry for noobing, but after what I've read and like you so my first code which worked with QTcpSocket(examples from Qt), I understand it in this way:
1.server is sending data and also at the begining of them server sends the size of data that were written to the socket
2. At the other side client is waiting for data but firstly gets the size, and then knows when to stop receiving the data.
It looked pretty like this in the examples and I've modified them for my needs. But now I see it isn't the right way when I use SSL however I can't understand it in 100% now, however I'm convinced that is a better method and more Qt-like, that it is why it is so important for me.
-
Re: QSslSocket vs QTcpSocket problem
Please make sure you understand the code I gave before using it. And never use code you do not understand.
-
Re: QSslSocket vs QTcpSocket problem
Please tell me before I will study hard your code, what do you mean by this line
processData(data) (I can't figure out when I should pull out the data I need and for example write the in to the file)
becouse I don't know how to refer to it, and maybe are there any signals I should take a closer look?
-
Re: QSslSocket vs QTcpSocket problem
processData() is a stub for your method for manipulating the data, the core of the server functionality. I don't know what your program is meant to do so I can't tell you what should be there.
-
Re: QSslSocket vs QTcpSocket problem
basically I am sending files. The server after establishing connection is sending many many files one by one.
-
Re: QSslSocket vs QTcpSocket problem
So probably processData() should store the data on the disk or somewhere else.
-
Re: QSslSocket vs QTcpSocket problem
But I have noticed that processData() is in if-condition, and as you can see from my "tests" the program is in that if-condition (you wrote) only once (at the first enter to the slot) and at that time data.size is 0.
-
Re: QSslSocket vs QTcpSocket problem
Did you adjust the sending side to the semantics of the receiving side or the other way round?
-
Re: QSslSocket vs QTcpSocket problem
It won't be enough if I just do sth like this?:
Code:
//serverfiles is a QStringList
out << (out,serverfiles);
serverSocket->write(block);
This code is in slot which starts thx to encrypted signal.
-
Re: QSslSocket vs QTcpSocket problem
No, not really. You are streaming in a QStringList and reading back 4 bytes assembled into integer and an anonymous block of data. How do you expect it to work?
-
Re: QSslSocket vs QTcpSocket problem
Becouse I still can't see how it should work this, I don't understand how to adjust the code at the server side(I am sending QSringList which has paths for the client becouse every file which will be received by client should be stored with one path from the received list). I still can't get a rid of this way of thinking about the problem, which was presented in the first post. I wrote it and understand it perfectlly. I still see it like this:
-server sends size of "thing" that will be sended in a second
-client receives size of "thing"(client know that firstly it will get the size)
-server sends the "thing"
-client knows that the "thing" will be now received and thx to the size(that it has just received), client knows how big the "thing" will be.
-
Re: QSslSocket vs QTcpSocket problem
Maybe you see it like this but you didn't implement it like this.
Quote:
-server sends size of "thing" that will be sended in a second
-server sends the "thing"
Quote:
Code:
//serverfiles is a QStringList
out << (out,serverfiles);
serverSocket->write(block);
Doesn't seem equivalent to me.
-
Re: QSslSocket vs QTcpSocket problem
ups it should look like this
Code:
out << (out, serverfiles.size());
serverSocket->write(block);
block.clear();
out << (out, serverfiles);
serverSocket->write(block);
block.clear();
This:
Code:
out << (out, serverfiles);
I've also found it in Qt Assistant-as a way of sending QtStringList in right way.
Generally as you can see when client connects to the server it always looks like this;
server sends QStringList
client sends his QStringList
server sends files
That is way my first code wasn't random in its simple construction.
-
Re: QSslSocket vs QTcpSocket problem
Well, the reading side is still different.
-
Re: QSslSocket vs QTcpSocket problem
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?
-
Re: QSslSocket vs QTcpSocket problem
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.
-
Re: QSslSocket vs QTcpSocket problem
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:
Code:
while(serverSocket->bytesAvailable() == 0)
{
QTextStream(stdout) <<
"Waiting for confirmation" <<endl;
}
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 You ;)
-
Re: QSslSocket vs QTcpSocket problem
Quote:
Originally Posted by
camol
I still don't understand why waitforReadyRead doesn't work in slot here with SSL slot
Ok, enough for me. I already told you why this happens in the very beginning. I'm not going to repeat myself.