简体   繁体   English

DatagramSocket.receive()因意外的SocketException而失败

[英]DatagramSocket.receive() failed with an unexpected SocketException

For an unconnected and bound DatagramSocket, the receive method call (with SO_TIMEOUT disabled) failed unexpectedly with the following Exception. 对于未连接和绑定的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)

Also I've not closed the socket explicitly. 我也没有明确关闭套接字。
This error occurred in Windows Server 2008 with JRE-6. Windows Server 2008中使用JRE-6发生此错误。

Even on calling DatagramSocket.close(), recreating a new DatagramSocket at the same socket address failed too. 即使在调用DatagramSocket.close()时,在同一个套接字地址重新创建一个新的DatagramSocket也失败了。

Can you please let me know the possible cause(s) for the error? 你能告诉我这个错误可能的原因吗?

I have met the same problem. 我遇到了同样的问题。
check the socket's "closed" and "connectState" fields. 检查套接字的“已关闭”和“connectState”字段。

/*
 * Connection state:
 * ST_NOT_CONNECTED = socket not connected
 * ST_CONNECTED = socket connected
 * ST_CONNECTED_NO_IMPL = socket connected but not at impl level
 */
static final int ST_NOT_CONNECTED = 0;
static final int ST_CONNECTED = 1;
static final int ST_CONNECTED_NO_IMPL = 2;

java.net.SocketException: socket closed java.net.SocketException:socket关闭

That means that you have closed the socket. 这意味着已关闭套接字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM