首页 > 技术文章 > 关于android socket出现at java.net.DatagramSocket java.net.BindException at libcore.io.IoBridge.bind(IoBridge.java:89)等waring

cpf123 2013-09-17 10:36 原文

   经查,是socket地址重复使用的原因,将代码做如下改变即可。

ctlClient = new DatagramSocket(TRANSCTLPORT);


ctlClient = new DatagramSocket(null);
ctlClient.setReuseAddress(true);
ctlClient.bind(new InetSocketAddress(TRANSCTLPORT));

 

推荐阅读