Results 1 to 3 of 3

Thread: QTcpSocket disconnected signal handling

  1. #1
    Join Date
    Oct 2010
    Posts
    18
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default QTcpSocket disconnected signal handling

    Hi.

    I wrote some programm which uses QTcpServer. I inherit some class from QTcpServer and in handleNewConnection method wrote something like this.

    Qt Code:
    1. while (hasPendingConnections())
    2. {
    3. QTcpSocket* client = nextPendingConnection();
    4. connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
    5. }
    To copy to clipboard, switch view to plain text mode 

    in clientDisconnected() slot i wrote something, for example printf("disconnected");

    And then i connect to this server using my Android Telnet client. When i connect to server using Windows Telnet client and then disconnected the clientDisconnected() method works and prints. But when i connect to Android Telnet client and then disconnect my phone from wifi, nothing prints, clientDisconnected() method not works.

    I have write another program which recieves packets from gprs. When mobile phone can not send or no gprs connection with operatorServer does not disconnected old connection, and mobile phone tries connect again. Same problem in this case.

    What is problem? Why is does not works?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTcpSocket disconnected signal handling

    Try:
    Qt Code:
    1. printf("disconnected\n");
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2010
    Posts
    18
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket disconnected signal handling

    Problem is not in "\n" end of string. Problem is in when clients loses internet connection for example when client is in place where no GSM/GPRS or 3G connection, QTcpServer don't no that client disconnected.

Similar Threads

  1. Replies: 6
    Last Post: 24th February 2012, 11:17
  2. QTcpSocket get disconnected when server is sending huge data
    By KernelCoder in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2011, 08:45
  3. Packet handling advice with QTcpSocket?
    By zAAm in forum General Programming
    Replies: 1
    Last Post: 27th April 2010, 15:23
  4. Handling signal-slot
    By sudhansu in forum Qt Programming
    Replies: 9
    Last Post: 31st January 2010, 09:32
  5. QTcpSocket - How do I know when it is disconnected ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 3rd April 2006, 21:05

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.