Results 1 to 4 of 4

Thread: client disconnected

  1. #1
    Join Date
    Oct 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Exclamation client disconnected

    Hello people I just programming a server / client
    Data exchange with QT5 .5 and i get a question.
    how can the server know that the client has closed the connection?

  2. #2
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: client disconnected

    Here is a good video series to get you started with understanding how networking works.

    https://www.youtube.com/watch?v=XaGX...oG3oKSuOcw_XeW

    I'm starting out with networking myself, so will be listening in to the responses .

  3. #3
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: client disconnected

    Assuming your server is implemented with QTcpServer, every time a new client connects your code should call QTcpServer::nextPendingConnection() to obtain a QTcpSocket through which to communicate with the client. When the client disconnects, the QTcpSocket first emits error(QAbstractSocket::RemoteHostClosedError), then disconnected(). All you have to do is connect those signals to slots that handle the situation.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: client disconnected

    Quote Originally Posted by carter88 View Post
    Hello people I just programming a server / client
    Data exchange with QT5 .5 and i get a question.
    how can the server know that the client has closed the connection?
    The socket has a disconnected() signal.

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 16th August 2015, 12:32
  2. curve disconnected?
    By lwz in forum Qwt
    Replies: 0
    Last Post: 11th April 2014, 03:28
  3. Replies: 6
    Last Post: 24th February 2012, 12:17
  4. database disconnected !
    By tinysoft in forum Newbie
    Replies: 1
    Last Post: 4th May 2011, 01:46
  5. QTcpSocket - How do I know when it is disconnected ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 3rd April 2006, 22:05

Tags for this Thread

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.