Results 1 to 3 of 3

Thread: Threaded server.

  1. #1
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Threaded server.

    Hi,
    I was trying to create a threaded tcp server which will create a new thread for each and every clients. so i passed the tcp socket descriptor to the corresponding thread. i have mapped the signal ready read in the same run function to the slot of an object created in the same thread's run. but i am getting an error. not actually an error but some run time problem. but on run time the clients are getting connected but, the ready read is not invoked even if data is sent. an exception is thrown by qt notifier.
    please help me out to solve the problem
    Nithin

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Threaded server.

    The problem is probably that you didn't run an event loop for each of the threads and maybe also created the sockets in the main thread context and you don't get notified of incoming socket events because they are not handled by the proper thread. Make sure you call QThread::exec() from each of the threads if you want to use signal-slot connections.

  3. #3
    Join Date
    Feb 2007
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Threaded server.

    well i dont know if this helps but i had the same problem , even after calling the exec

    in the run method, the problem was i used the built in QTcpServer socket , hooked a slot at

    connected signal, called the pendingConnection function , took socketdescriptor of the

    QTcpSocket returned by the function created my QThread class instance passing the

    socketdesicritor. The point to remeber is even if you created a TcpSocket and set the

    scoket descriptor in the run method , it wont work. so inherit from QTcpServer class and

    override the incoming connection function take the socketdescriptor passed in start your custom thead here passing the descriptor, and create the QTcpSocket class instance
    from run function and set the passed descriptor.

Similar Threads

  1. How to download any file through ftp server
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2007, 01:23
  2. How to ping a server ?
    By Nyphel in forum Newbie
    Replies: 2
    Last Post: 23rd April 2007, 11:27
  3. cannot connect to X server
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2007, 14:22
  4. How a server can write "Hello" to a browser ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 1st December 2006, 14:43
  5. synching client readings to server output
    By OnionRingOfDoom in forum Qt Programming
    Replies: 14
    Last Post: 28th January 2006, 18:15

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.