Related to : PyQt 4.6.1
This is regarding a simple socket reading in my application.
I am using QAbstractSocket.UdpSocket for the purpose.
Once the socket is connected to given host and port, it should constantly watch for data.

Question 1:
Do I have to use a thread to watch socket for data being available or signal "readyRead" will
do this job?

Question 2:
Code for sending data on socket:
Qt Code:
  1. socket = QtNetwork.QAbstractSocket(QtNetwork.QAbstractSocket.UdpSocket, self)
  2. socket.connectToHost(host, port)
  3. socket.writeData("This is the test string.")
  4. socket.disconnectFromHost()
  5. socket.close()
To copy to clipboard, switch view to plain text mode 
The line:
Qt Code:
  1. socket.writeData("This is the test string.")
To copy to clipboard, switch view to plain text mode 
is crashing the application. why?

Question 3:
What's the proper way to close a socket?
I am using:
Qt Code:
  1. self.socket.disconnectFromHost()
  2. self.socket.waitForDisconnected()
  3. self.socket.close()
To copy to clipboard, switch view to plain text mode 
When I am closing the socket using above code, no error or warning is produced, but when I close the dialog box where I am implementing my tests, message is printed to stdout:
Qt Code:
  1. QWaitCondition: Destroyed while threads are still waiting
To copy to clipboard, switch view to plain text mode 

Please be patient, I have a limited knowledge on threads and sockets.