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.
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,
_