View Full Version : Why is my server crashing?

16th November 2013, 14: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");

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

16th November 2013, 20: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...

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...

16th November 2013, 20: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()?