Results 1 to 3 of 3

Thread: emit error for QLocalSocket

  1. #1
    Join Date
    Apr 2011
    Location
    Hyderabad, India
    Posts
    25
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default emit error for QLocalSocket

    Hi,

    I am implementing 'Local fortune server' example (from Qt 4.7.3) as a service on Windows.
    What i want is that when someone paused the service, the local server should notify the error to the connected local socket (local fortune client). The error can be QLocalSocket::ServerNotFoundError.
    Now, How to generate this error from server example. Please look at the following code where i want to generate this error.


    Qt Code:
    1. void FortuneServer::incomingConnection(quintptr socketDescriptor)
    2. {
    3. if (disabled) {
    4. [B]// here i want to emit QLocalSocket::ServerNotFoundError [/B]
    5. return;
    6. }
    7.  
    8. QString fortune = fortunes.at(qrand() % fortunes.size());
    9. FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
    10. connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    11. thread->start();
    12. }
    13.  
    14. void FortuneServer:: pause()
    15. {
    16. disabled = true;
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by high_flyer; 31st August 2011 at 08:53. Reason: code tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: emit error for QLocalSocket

    I am not sure what is the problem you have.
    From what I understand you don't have a problem with pausing your service, and to know that it is paused right?
    If that is correct, then what is left is that you don't know how to send a message to your client?
    If so, do it just like it was a fortune cookie.
    Just make a new kind of message, lets say StatusMsg, and insert the logic in the client to react to that sort of messages, analogue to the fortune cookies.
    If its neither, please explain more.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    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: emit error for QLocalSocket

    I think he doesn't want to send a message. He wants the connection from the client to be rejected. Personally I don't think this makes sense, in such situation one could just remove the local socket.
    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.


  4. The following user says thank you to wysota for this useful post:

    raj_iv (2nd September 2011)

Similar Threads

  1. QLocalSocket issue/difference between *nix & win32
    By CmdrMoozy in forum Qt Programming
    Replies: 9
    Last Post: 30th January 2012, 15:18
  2. Transparent QLocalSocket and QTcpSocket use
    By chiiph in forum Qt Programming
    Replies: 0
    Last Post: 12th November 2010, 16:35
  3. QLocalSocket Synchronicity
    By matic in forum Qt Programming
    Replies: 0
    Last Post: 25th March 2010, 12:04
  4. Using QLocalServer and QLocalSocket
    By danc81 in forum Qt Programming
    Replies: 0
    Last Post: 10th November 2009, 12:09
  5. IPC with QLocalServer/QLocalSocket
    By ManuMies in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2009, 20:09

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.