Re: Qt Network Programming
Could you run your application through a debugger and print the backtrace?
Re: Qt Network Programming
If there are no pending connections then nextPendingConnection returns NULL.
You should test for that before calling clientConnection->write().
Regards
Re: Qt Network Programming
I can't understand your code when compared to your flow diagram.
What is this part for?:
Code:
out.device()->seek(0);
out << (quint16)(block.size() - sizeof(quint16));
Also, I am not sure this slot is a good place for:
Code:
QTcpSocket *clientConnection
= tcpServer
->nextPendingConnection
();
Since you assume that every time you get data from what ever socket, there is another pending connection - and there is no assurance for that.
So this code:
Code:
QTcpSocket *clientConnection
= tcpServer
->nextPendingConnection
();
clientConnection->write(block);
Is probably what is crashing your application, when clientConnection is NULL.
At the very least you should test it first:
Code:
if(tcpServer->hasPendingConnections()
{
clientConnection = tcpServer->nextPendingConnection();
clientConnection->write(block);
}
EDIT: beat to it by marcel :)
Re: Qt Network Programming
Quote:
Originally Posted by
wysota
Could you run your application through a debugger and print the backtrace?
OMG!
What do you mean with the backtrace?
You know, .... I am one of the newbs! ;-)
Re: Qt Network Programming
Thx High_flyer,
Thx marcel
I am going to test this and I will reconsider my code, and if I have any further problems, you will tell you! ;-)
Many thx to you!