Android 中出現java.net.BindException: bind failed: EADDRINUSE 問題解決辦法
看下問題:
try{DatagramSocket udpSocket = new DatagramSocket(DEFAULT_PORT );} catch (Exception e){e.printStackTrace();}//java.net.BindException: bind failed: EADDRINUSE (Address already in use)解決方法:
將:udpSocket = new DatagramSocket(DEFAULT_PORT );
改為:
if(udpSocket==null){udpSocket = new DatagramSocket(null);udpSocket.setReuseAddress(true);udpSocket.bind(new InetSocketAddress(DEFAULT_PORT));}問題就解決了
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答