Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]How the server side know if client side disconnect by crash or some unexpect action?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]How the server side know if client side disconnect by crash or some unexpect action?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BBFAG3
    wrote on last edited by
    #1

    I tired the SIGNAL "disconnect()", but it doesn't work when client close by crash or disable the network.
    I have a idea that server will send packet to client regularly, if client won't reply, I will mark it to "offline".
    Will that work?

    Thanks a lot!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      drhalftone
      wrote on last edited by
      #2

      Should work, but it doesn't sound right that you are not receiving the disconnect signal. Can you post some code showing how you created the TcpSocket object to handle the incoming connection? Here is what I use:
      @ socket=this->nextPendingConnection();
      connect(socket, SIGNAL(readyRead()), this, SLOT(onReadyRead()), Qt::QueuedConnection);
      connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onTcpError(QAbstractSocket::SocketError)), Qt::QueuedConnection);
      connect(socket, SIGNAL(disconnected()), this, SLOT(onDisconnected()), Qt::QueuedConnection);
      @

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BBFAG3
        wrote on last edited by
        #3

        I connect the SIGNAL and SLOT when it's still empty.......

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KA51O
          wrote on last edited by
          #4

          Maybe your problem is related to the problem I'm facing at the moment. Have a look at "this thread":http://qt-project.org/forums/viewthread/38640/. The behaviour seems to differ when the sockets connected to each other loose their connection due to for example a physical disconnect (e.g. network cable unplugged) the client crashing might have the same effect, since he cannot send a disconnect message.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            drhalftone
            wrote on last edited by
            #5

            [quote author="BBFAG3" date="1392889679"]I connect the SIGNAL and SLOT when it's still empty.......[/quote]

            You'll have to forgive me, but what does it mean to be, "empty?" And what is it that is, "empty?"

            1 Reply Last reply
            0
            • B Offline
              B Offline
              BBFAG3
              wrote on last edited by
              #6

              [quote author="drhalftone" date="1392903905"]
              [quote author="BBFAG3" date="1392889679"]I connect the SIGNAL and SLOT when it's still empty.......[/quote]

              You'll have to forgive me, but what does it mean to be, "empty?" And what is it that is, "empty?"[/quote]

              I mean...I created a QTcpSocket and connect the slot before I use server.nextPendingConnection()...Forgive my English....My native language is not English

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved