Results 1 to 2 of 2

Thread: How to close socket on timeout?

  1. #1
    Join Date
    Feb 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to close socket on timeout?

    I read http://www.qtcentre.org/wiki/index.p...hout_threading. So I have a small question. What's right way for server to close inactive sockets?

    1. Store timestamp for every opened socket.
    2. Update timestamp on every Read/Write operation.
    2. Make single QTimer and by QTimer::timeout check what socket is expired.

    Or:

    1. Create QTimer pool for server and QTimer object for every socket.
    2. Connect all timers to a single server slot slotTimeout.
    3. Restart socket timer on each Read/Write operation.
    3. In server slotTimeout close expired socket.

    Or something else?

  2. #2
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to close socket on timeout?

    IMHO, p.1
    1. Store timestamp for every opened socket.
    2. Update timestamp on every Read/Write operation.
    2. Make single QTimer and by QTimer::timeout check what socket is expired.
    as only one QTimer for all sockets - that is saving (minimizing) resources.

Similar Threads

  1. Replies: 2
    Last Post: 17th December 2010, 19:01
  2. QProcess timeout
    By MonkeyJLuffy in forum Qt Programming
    Replies: 8
    Last Post: 22nd April 2010, 12:42
  3. QHttp Timeout?
    By musaulker in forum Newbie
    Replies: 4
    Last Post: 25th February 2010, 09:43
  4. QBasicTimer never timeout.
    By kunalnandi in forum Qt Programming
    Replies: 5
    Last Post: 30th January 2010, 07:55
  5. Tootip Timeout
    By rajeshs in forum Qt Programming
    Replies: 1
    Last Post: 23rd July 2008, 10:17

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.