android java.net.BindException: bind failed: EADDRINUSE (Address already in use)

今天遇到一种情况,在手机上发广播包,在4.4.2上的手机会发生,4.1.2和4.0.2都没有遇见,问题是这样的

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));

}

问题就解决了

时间: 2024-10-08 13:58:11

android java.net.BindException: bind failed: EADDRINUSE (Address already in use)的相关文章

java.net.BindException: Cannot assign requested address

tomcat启动后报错 2017-6-7 17:23:49 org.apache.catalina.core.StandardServer await 严重: StandardServer.await: create[localhost:8005]: java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.Pl

Tomcat启动时报StandardServer.await: create[8005]: java.net.BindException: Cannot assign requested address: JVM_Bind

问题描述: 今天一早,所有淡定下来后准备启动本地Tomcat,突然出现一堆错误: 严重: StandardServer.await: create[8005]: java.net.BindException: Cannot assign requested address: JVM_Bind at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.

Tomcat启动报错:严重: StandardServer.await: create[8005] java.net.BindException: Cannot assign requested address

org.apache.catalina.core.StandardServer await        SEVERE: StandardServer.await: create[8005]:        java.net.BindException: Cannot assign requested address java.net.BindException: Cannot assign requested address        at java.net.PlainSocketImpl

tomcat java.net.BindException: Cannot assign requested address 解决方法

今天线上TOMCAT启动时遇到了下比较麻烦的问题,错误如下: 21-Apr-2016 15:14:19.077 SEVERE [main] org.apache.catalina.core.StandardServer.await StandardServer.await: create[localhost:8015]: java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.sock

Tomcat启动异常 java.net.BindException: Cannot assign requested address: JVM_Bind

从Apache官网下载的tomcat7,在MyEclipse中启动时抛出如下异常: 严重: StandardServer.await: create[localhost:8005]: java.net.BindException: Cannot assign requested address: JVM_Bind at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(Plain

Caused by: java.net.BindException: Cannot assign requested address: JVM_Bind问题

Caused by: java.net.BindException: Cannot assign requested address: JVM_Bind更改这个问题可以从两方面着手:一:查看ip和端口是否正确(大多数都是这个问题引起的)二:查看端口是否被占用了

Problem binding to [yarn.com:8031] java.net.BindException: Cannot assign requested address

at org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.main(ResourceManager.java:1467)Caused by: java.net.BindException: Problem binding to [yarn.com:8031] java.net.BindException: Cannot assign requested address; For more details see: 是由于虚拟

端口占用的一种形式 Failed to initialize end point associated with ProtocolHandler ["ajp-bio-8090"] java.net.BindException: Address already in use: JVM_Bind <null>:8090

严重: Failed to initialize end point associated with ProtocolHandler ["ajp-bio-8090"]java.net.BindException: Address already in use: JVM_Bind <null>:8090 at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:413) at org.apache.tomc

解决springboot 出现异常: java.net.BindException: Address already in use: bind

解决springboot 出现异常: java.net.BindException: Address already in use: bind 这是引文在启动springboot 的时候,没有关闭端口号8080(或者自定义的端口号),需要进行手动关闭. 操作步骤: 1,windows+R -->cmd,进入命令窗口. 2,命令行内输入 :netstat   -ano|findstr  8080 8080指的是你启动的时候的端口号 查找最后一列的pid. 命令行输入: taskkill  /pid