In my application there will be one thread which always be running and will be sending or listening to some port.
This application runs in the background. Sometimes while creating the socket, i found that the port which was used by the same thread before, is not getting released on close() of the socket. So i tried like this
dc = new DatagramSocket(inetAddr);
dc.setReuseAddress(true);
The problem is , it is not reaching to the second line also. in the first line itself i am getting the expcetion BindException: Address already in use
.
Can anyone please help me how to handle this is situation.
Is there any way to release the port ?
Thanks & Regards,
SSuman185
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…