开发者

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.

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开发者_如何学Go) for the error?


I have met the same problem.
check the socket's "closed" and "connectState" fields.

/*
 * 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

That means that you have closed the socket.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜