DatagramSocket.receive() 失败并出现意外的 SocketException
对于未连接且绑定的 DatagramSocket,接收方法调用(禁用 SO_TIMEOUT)意外失败,并出现以下异常。
java.net.SocketException: socket closed
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
at java.net.DatagramSocket.receive(DatagramSocket.java:712)
另外我还没有显式关闭套接字。
此错误发生在带有 JRE-6 的 Windows Server 2008 中。
即使调用 DatagramSocket.close(),在同一套接字地址重新创建新的 DatagramSocket 也会失败。
您能让我知道错误的可能原因吗?
For an unconnected and bound DatagramSocket, the receive method call (with SO_TIMEOUT disabled) failed unexpectedly with the following Exception.
java.net.SocketException: socket closed
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
at java.net.DatagramSocket.receive(DatagramSocket.java:712)
Also I've not closed the socket explicitly.
This error occurred in Windows Server 2008 with JRE-6.
Even on calling DatagramSocket.close(), recreating a new DatagramSocket at the same socket address failed too.
Can you please let me know the possible cause(s) for the error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也遇到了同样的问题。
检查套接字的“关闭”和“连接状态”字段。
I have met the same problem.
check the socket's "closed" and "connectState" fields.
这意味着您已经关闭了套接字。
That means that you have closed the socket.