DatagramSocket change port


At startup of my app, after instantiated an object DatagramSocket, I connect it to port 8888 calling method bindToPort.

Then I have a button that, if pressed, whant to bind the port to 7777, but when I do it both calling directly bindToPort() or calling before shutdown() and after bindToPort(), it ever fails…

How can I achieve it?