Results 1 to 7 of 7

Thread: thread with socket?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: thread with socket?

    Sockets can be used in blocking (synchronous) and non-blocking (asynchronous) fashion. Non-blocking use of sockets does not require threads because it relies on signals and event loops.

    There are two samples available:

    Blocking sockets

    http://doc.trolltech.com/4.4/network...uneclient.html

    Look at fortunethread.cpp

    Non-blocking sockets

    http://doc.trolltech.com/4.4/network-fortuneclient.html

    Look at client.cpp

    This document gives more background on these two usages of sockets: http://doc.trolltech.com/4.4/qtnetwo...and-qtcpserver

    And this document provides some information on using event loops within threads: http://doc.trolltech.com/4.4/threads...ead-event-loop

    It is hard to be more specific without knowing what MyThread::run() looks like.
    Last edited by yuriry; 24th September 2008 at 06:20.

Similar Threads

  1. Socket on a Thread
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2008, 15:56
  2. Thread, Timer and Socket. Comuication problem
    By ^NyAw^ in forum Qt Programming
    Replies: 6
    Last Post: 17th January 2008, 16:48
  3. socket in thread error!
    By alphaboy in forum Qt Programming
    Replies: 6
    Last Post: 18th November 2007, 12:15
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. How to write on a socket in another thread?
    By Valheru in forum Qt Programming
    Replies: 7
    Last Post: 12th October 2006, 10:52

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.