Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to unbind DatagramSocket

843790Jul 21 2007 — edited Jul 24 2007
Hi,

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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 21 2007
Added on Jul 21 2007
7 comments
5,011 views