Results 1 to 4 of 4

Thread: Why is my server crashing?

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Why is my server crashing?

    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?
    Qt Code:
    1. void AsicamtheServer::incomingConnection(int handle)
    2. {
    3. socketDescriptor = handle;
    4. QTcpSocket *socket = this->nextPendingConnection();
    5.  
    6. socket->write("Hello client");
    7. socket->flush();
    8. socket->waitForBytesWritten(3000);
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why is my server crashing?

    does anybody know hoow to fix this?

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Why is my server crashing?

    I think to is many object to close... wen you dont close all crash fast

    Qt Code:
    1. /// open and connect to close...
    2. QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
    3. connect(clientConnection, SIGNAL(disconnected()),
    4. clientConnection, SLOT(deleteLater()));
    5.  
    6. /// write item and close...
    7. clientConnection->write(block);
    8. clientConnection->disconnectFromHost();
    To copy to clipboard, switch view to plain text mode 

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

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Why is my server crashing?

    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()?
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. Strange crashing
    By Radek in forum Newbie
    Replies: 2
    Last Post: 5th June 2013, 05:45
  2. Qwt app crashing
    By K4ELO in forum Qwt
    Replies: 0
    Last Post: 25th March 2013, 12:57
  3. Crashing without debug mode- No crashing with gdb debugger
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2011, 11:27
  4. [TCP Server] Server only sending when terminating
    By papperlapapp in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2010, 19:41
  5. Application is Crashing
    By shyam prasad in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2007, 17:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.