I have tried this and failed. At the start my application, I am creating a QUdpSocket and binding it with a port number and any_addr option. my application requires that, I have to change the port number with new one when the application is still running. Just before changing the port number, im disconnecting the socket from host and binding again with new port number and again establishing the connection for reading. but the same thing is not happening, the application, simply is not starting at all with all those options mentioned above.

Qt Code:
  1. application()
  2. {
  3. udpSocket = new QUdpSocket();
  4. udpSocket->bind(portNum,QUdpSocket::ShareAddress);
  5. QObject::connect(udpSocket,SIGNAL(readyRead()),SLOT(readData()));
  6. }
  7. in some other function, I am doing this to assign a new port number to the socket.
  9. rebindPort(int newPortNum)
  10. {
  11. udpSocket->disconnectFromHost();
  12. // udpSocket->abort();
  13. udpSocket->bind(newPortNum,QUdpSocket::ShareAddress);
  14. QObject::connect(udpSocket,SIGNAL(readyRead()),SLOT(readData()));
  15. }
To copy to clipboard, switch view to plain text mode 

can I rebind the socket with a new port number like that? do i have to delete the socket and redo everything if i have to rebind the socket with a new port number as the application is running?
whats wrong with this. pls post a suggestion. thank u.