Results 1 to 2 of 2

Thread: QTcpSocket in QThread Problem In Qt5.1

  1. #1
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default QTcpSocket in QThread Problem In Qt5.1

    I’ve created a QThread and in run method i have a QTcpSocket variable. It successfully send data to the client. But when the program exit from run function, and I create another thread with the same socket descriptor it fails to send data. The error is : “Invalid Socket Descriptor”. It seems that the first QTcpSocket is not deleted correctly and it uses the port so the second thread with the same port can not open it. Please Advice.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket in QThread Problem In Qt5.1

    it is more likely that the first QTcpSocket instance is in fact deleted correctly and has thus closed the file descriptor associated with the socket.

    Why would you want to use the same socket in two threads and not just use one thread per connection?
    Or actually, why use threads at all?

    Cheers,
    _

Similar Threads

  1. Problem with QTcpSocket and QThread
    By ivansjg in forum Qt Programming
    Replies: 5
    Last Post: 19th May 2010, 14:53
  2. QTcpSocket in QThread
    By zverj in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2009, 09:27
  3. QTcpSocket in QThread
    By Alex Snet in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2009, 19:02
  4. Problem with QTcpSocket in QThread
    By Raistlin in forum Qt Programming
    Replies: 8
    Last Post: 6th October 2007, 12:23
  5. QThread and QTcpSocket problem
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2006, 09:57

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.