[英]How to catch JVM_Bind exception: java.net.BindException: Address already in use
How can i catch the Bind exception? 如何捕获绑定异常? i used the following lines
我用了以下几行
try{
//some code
}
catch (java.net.BindException e) {
//some code
}
and 和
try{
//some code
}catch (BindException e) {
//some code
}
but none of them is working giving me the error 但他们都没有给我错误
`java.net.BindException: Address already in use: JVM_Bind
java.net.DualStackPlainSocketImpl.bind0(Native Method)
java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
java.net.ServerSocket.bind(ServerSocket.java:376)
java.net.ServerSocket.<init>(ServerSocket.java:237)
...
Can anybody give me an idea? 有人可以给我一个主意吗? Thanks in advance :)
提前致谢 :)
Are you sure that the try
block surrounds the code that throws the exception? 您确定
try
块包含引发异常的代码吗? I say, either it's not, or that the BindException
is wrapped with some other Throwable
before thrown. 我说,要么不是,要么
BindException
在抛出之前被其他Throwable
包装。 In that case, try 在这种情况下,请尝试
try {
// the problematic code
} catch (Throwable t) { // <--- here, Throwable
// better log the error here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.