How to unbind DatagramSocket
843790Jul 21 2007 — edited Jul 24 2007Hi,
I have a problem with DatagramSocket. Though I close() it and disconnect(), I cannot reuse the port allocated by previous socket in another socket:
Caused by: java.net.BindException: Address already in use
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82)
at java.net.DatagramSocket.bind(DatagramSocket.java:368)
at java.net.DatagramSocket.<init>(DatagramSocket.java:210)
at java.net.DatagramSocket.<init>(DatagramSocket.java:261)
...
What is the correct way to unbind the socket?
Thanks for any help.