Walsi
25th May 2007, 09:50
Hy!
I got a problem with small Qt Network application. I got a Client and a Server which communicates with TCP. I want, that they are able to send messages to each other. I am in an early development stage of this application and I am testing fundamental function at the moment. Following flowchat describes the problem.
..............CLIENT.............................. .................SERVER
........................TCP connect [SYN], [SYN,ACK], [ACK]
....................<---------------- ---------------------------------->
....................<----------------------------------------------------- ......sendResponse
.....................................TCP Message [PSH].................................Button
....................----------------------------------------------------->
..................................TCP Acknowledge [ACK]
display the
message
.................................................. ..........................<---- *
When I try to send at the end of the flowchat (at *) I got the Message on the console of the Server: SEGMENTATION Fault
The SourceCode for sending messages on the Server is following:
void Server::sendResponse()
{
QString responseMessage;
responseMessage = "ACK Hello";
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_0);
out << (quint16)0;
out << responseMessage;
out.device()->seek(0);
out << (quint16)(block.size() - sizeof(quint16));
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
clientConnection->write(block);
}
What is the problem, what can do to solve it?
Best Regards!
I got a problem with small Qt Network application. I got a Client and a Server which communicates with TCP. I want, that they are able to send messages to each other. I am in an early development stage of this application and I am testing fundamental function at the moment. Following flowchat describes the problem.
..............CLIENT.............................. .................SERVER
........................TCP connect [SYN], [SYN,ACK], [ACK]
....................<---------------- ---------------------------------->
....................<----------------------------------------------------- ......sendResponse
.....................................TCP Message [PSH].................................Button
....................----------------------------------------------------->
..................................TCP Acknowledge [ACK]
display the
message
.................................................. ..........................<---- *
When I try to send at the end of the flowchat (at *) I got the Message on the console of the Server: SEGMENTATION Fault
The SourceCode for sending messages on the Server is following:
void Server::sendResponse()
{
QString responseMessage;
responseMessage = "ACK Hello";
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_0);
out << (quint16)0;
out << responseMessage;
out.device()->seek(0);
out << (quint16)(block.size() - sizeof(quint16));
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
clientConnection->write(block);
}
What is the problem, what can do to solve it?
Best Regards!