即使在应用程序崩溃后,IPV6 ServerSocket仍在侦听 [英] IPV6 ServerSocket is still listening even after application crash

查看:72
本文介绍了即使在应用程序崩溃后,IPV6 ServerSocket仍在侦听的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下方法创建了一个ServerSocket:

I created a ServerSocket using:

InetSocketAddress inetsktaddr = new InetSocketAddress(0);
ServerSocket sckt = new ServerSocket();
sckt.bind(inetsktaddr);
Socket socket = sckt.accept();

使用我发现的netstat在应用程序运行时

when the application is running, using netstat i found,

TCP    0.0.0.0:49906          0.0.0.0:0              LISTENING       9196
TCP    [::]:49906             [::]:0                 LISTENING       9196

有时在应用程序崩溃时,netstat结果显示:

SOMETIMES WHEN THE APPLICATION CRASHES, netstat result says:

TCP    [::]:49906             [::]:0                 LISTENING       9196

当搜索进程ID 9196时,不存在这样的进程.应用程序运行时,它是java.exe进程ID.发生这种情况的原因是什么?

when searched for the process id 9196, no such process exists. It was the java.exe process id when the application was running. What is the reason for this to happen?

我正在使用Java 1.5和Windows 7 Professional

编辑

一段时间后,我发现了以下内容: 我的应用程序启动mysql数据库.有时当java.exe崩溃时,mysql也不会崩溃.数据库服务器将仅启动.当出现此问题(:::独自处于侦听状态)时,我杀死了mysql进程,立即::套接字停止侦听.因此,mysql在Java崩溃时会以某种方式阻止::消失.找不到原因.

After sometime i found the following: my application starts mysql database. Sometimes when java.exe crashes, mysql will not crash. The db server will be up only. When this issue came (:: alone in listening state), i killed mysql process, immediately that :: socket stopped listening. So mysql is somehow preventing the :: to go away when java crashes. Not able to find reason for it.

推荐答案

我终于找到了原因,它是JVM错误. ( http://bugs.java.com/bugdatabase/view_bug.do?bug_id= 6598160 )

Atlast i found the reason, its a JVM Bug. (http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6598160)

子进程将仅继承IPV6套接字句柄,而不继承IPV4套接字句柄.因此,问题来了.

Child processes will inherit ONLY IPV6 SOCKET HANDLES AND NOT IPV4 SOCKET HANDLES. Hence the issue came to me.

修复是我应该升级JVM还是仅在ipv4服务器套接字中侦听.

Fix is i should either upgrade JVM or listen only in ipv4 server socket.

这篇关于即使在应用程序崩溃后,IPV6 ServerSocket仍在侦听的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆