How to change DatagramSocket port number on the fly?

I want to be able to change the UDP port number of a receiving process more or less on the fly.
I have this function which changes the port number but it does not receive data on the new port until the app is restarted (the changed port number is saved/restored elsewhere).

void Udp2MidiThread::changeUDPport(int newport){

     stopThread(5000);
     skt->shutdown();
     delete(skt);

     skt = new(DatagramSocket);
     skt->bindToPort(newport);
     run();
}

Perhaps there is a basic mistake above…