Results 1 to 5 of 5

Thread: QLocalServer with multiple clients — proper handling

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Posts
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QLocalServer with multiple clients — proper handling

    I think your approach is well thought, altough I don't find the difference with my multiple instances of a handler class (SocketHandler) except that it's not a socket (it does not inherit QLocalSocket) but QLocalSocket is composited as a member variable.

    I believe it's not related to the disconnection (and pipe-handle leaking) problem, but who cares, I will try your idea.

  2. #2
    Join Date
    Sep 2009
    Posts
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QLocalServer with multiple clients — proper handling

    I implemented your solution, but I still keep getting pipe handles not closed.

    For each connection, Qt creates the following named pipes:

    Qt Code:
    1. \Device\NamedPipe\Win32Pipes.00001490.0000000X
    2. \Device\NamedPipe\<SERVER_KEY>
    To copy to clipboard, switch view to plain text mode 

    The second that includes the server key in the pipe name is the type of pipe handles that are not closing.

    May be it's an error in my client.
    When my client tries to shutdown the connection, the socket error slot signals, with:

    QLocalSocketPrivate::completeAsyncRead: Connection error

    My client application calls _socket->disconnectFromServer() in the aboutToQuit() handler slot (prior to app quitting).

    I related the problem to the eventloop not already responding on the aboutToQuit(), but I tried on other program sections, when the event loop is well alive, and it didn't work. Nevertheless, sockets will get deleted on clean program close, so I think I should not bother manually disconnecting.

  3. #3
    Join Date
    Sep 2009
    Posts
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QLocalServer with multiple clients — proper handling



    Fixed by letting the server-side closing the socket on disconnection signal. The client just does not nothing, just waits the server to close and delete the QLocalSocket pointer on disconnection.

    Thanks, anyway.

Similar Threads

  1. Proper handling "Cancel" click for QWizard
    By Splinter in forum Qt Programming
    Replies: 4
    Last Post: 17th September 2012, 14:34
  2. Replies: 7
    Last Post: 10th May 2010, 11:26
  3. Extend QTcpServer to handle multiple clients
    By DiamonDogX in forum Qt Programming
    Replies: 5
    Last Post: 24th February 2010, 19:49
  4. Handling multiple forms
    By msmihai in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2008, 13:41
  5. Handling multiple UDP sockets
    By ecphora in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 20:01

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
  •  
Qt is a trademark of The Qt Company.