java.net.BindException: bind failed: EADDRINUSE (Address already in use)
2012-12-14 16:33
821 查看
E/NMPWIFI ( 1189): java.net.BindException: bind failed: EADDRINUSE (Address already in use)
W/System.err( 1189): java.net.BindException: bind failed: EADDRINUSE (Address already in use)
W/System.err( 1189): at libcore.io.IoBridge.bind(IoBridge.java:89)
W/System.err( 1189): at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:68)
W/System.err( 1189): at java.net.DatagramSocket.createSocket(DatagramSocket.java:133)
W/System.err( 1189): at java.net.DatagramSocket.<init>(DatagramSocket.java:78)
W/System.err( 1189): at com.nmp.nmpdmc.NMPWIFI$ReceiveUdp.run(NMPWIFI.java:276)
W/System.err( 1189): Caused by: libcore.io.ErrnoException: bind failed: EADDRINUSE (Address already in use)
W/System.err( 1189): at libcore.io.Posix.bind(Native Method)
W/System.err( 1189): at libcore.io.ForwardingOs.bind(ForwardingOs.java:39)
W/System.err( 1189): at libcore.io.IoBridge.bind(IoBridge.java:87)
W/System.err( 1189): ... 4 more
解决方法:
将:udpSocket = new DatagramSocket(DEFAULT_PORT );
改为:
if(udpSocket==null){
udpSocket = new DatagramSocket(null);
udpSocket.setReuseAddress(true);
udpSocket.bind(new InetSocketAddress(DEFAULT_PORT));
}
W/System.err( 1189): java.net.BindException: bind failed: EADDRINUSE (Address already in use)
W/System.err( 1189): at libcore.io.IoBridge.bind(IoBridge.java:89)
W/System.err( 1189): at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:68)
W/System.err( 1189): at java.net.DatagramSocket.createSocket(DatagramSocket.java:133)
W/System.err( 1189): at java.net.DatagramSocket.<init>(DatagramSocket.java:78)
W/System.err( 1189): at com.nmp.nmpdmc.NMPWIFI$ReceiveUdp.run(NMPWIFI.java:276)
W/System.err( 1189): Caused by: libcore.io.ErrnoException: bind failed: EADDRINUSE (Address already in use)
W/System.err( 1189): at libcore.io.Posix.bind(Native Method)
W/System.err( 1189): at libcore.io.ForwardingOs.bind(ForwardingOs.java:39)
W/System.err( 1189): at libcore.io.IoBridge.bind(IoBridge.java:87)
W/System.err( 1189): ... 4 more
解决方法:
将:udpSocket = new DatagramSocket(DEFAULT_PORT );
改为:
if(udpSocket==null){
udpSocket = new DatagramSocket(null);
udpSocket.setReuseAddress(true);
udpSocket.bind(new InetSocketAddress(DEFAULT_PORT));
}
相关文章推荐
- java.net.BindException: bind failed: EADDRINUSE (Address already in use)
- {已经解决}android java.net.BindException: bind failed: EADDRINUSE (Address already in use)
- java.net.BindException: bind failed: EADDRINUSE (Address already in use)
- Android 关于java.net.BindException: bind failed: EADDRINUSE (Address already in use)
- android java.net.BindException: bind failed: EADDRINUSE (Address already in use)
- java.net.BindException: bind failed: EADDRINUSE (Address already in use)
- java.net.BindException: Address already in use (Bind failed)
- IDEA错误:Failed to start end point associated with ProtocolHandler [http-nio-9999] java.net.BindException: Address already in use: bind
- 【tomcat】启动报错:Failed to initialize end point associated with ProtocolHandler ["http-apr-8080"] java.lang.Exception: Socket bind failed 和java.net.BindException: Address already in use: JVM_Bind错误解决
- java.net.BindException: Address already in use <null>:8081
- java.net.BindException: Address already in use: JVM_Bind
- myeclipse中Caused by: java.net.BindException: Address already in use: JVM_Bind
- StandardServer.await: create[8005]java.net.BindException: Address already in use: JVM_Bind错误
- java.net.BindException: Address already in use: JVM_Bind
- java.net.BindException: Address already in use: JVM_Bind <null>:8001解决办法
- tomcat运行时候出现java.net.BindException: Address already in use: JVM_Bind错误解决方法
- StandardServer.await: create[8005]: java.net.BindException: Address already in use: JVM_Bind
- Unable to open debugger port (127.0.0.1:49688): java.net.BindException "Address already in use: JVM_
- java.net.BindException: Address already in use: JVM_Bind
- 启动Tomcat 出现java.net.BindException:Address already in use:JVM_Bind