PDA

View Full Version : Why is my server crashing?



ayanda83
16th November 2013, 13:31
Hi every one, I'm writing this client server app. the server runs fine until I try connecting to it. when I telnet the server, it crashes. the portion the the code that crashes my server is the one below. when I comment out the line socket->write("Hello Client"); the server does not crash when i "telnet" it. what could be causing my server to crash?

void AsicamtheServer::incomingConnection(int handle)
{
socketDescriptor = handle;
QTcpSocket *socket = this->nextPendingConnection();

socket->write("Hello client");
socket->flush();
socket->waitForBytesWritten(3000);
}

ayanda83
16th November 2013, 16:18
does anybody know hoow to fix this?

patrik08
16th November 2013, 19:01
I think to is many object to close... wen you dont close all crash fast



/// open and connect to close...
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
connect(clientConnection, SIGNAL(disconnected()),
clientConnection, SLOT(deleteLater()));

/// write item and close...
clientConnection->write(block);
clientConnection->disconnectFromHost();



all work in this world is: 1, start 2, change 3, stop
if you start and start and other time start you lost a lot of energy ....
google search The Anatomy of Confusion .. The Doctrine of the Stable Datum The Anatomy of Control The “Secret” of Efficiency L.R.Hubbard and Buddha 8000 years ago...

ChrisW67
16th November 2013, 19:49
Use your debugger to see why it is crashing at that line. What is the value of socket? How can socket get that value? How can your program get to this point if socket gets that value? Have you read the docs for QTcpServer::nextPendingConnection()?