为什么会出现此错误:java.net.PlainSocketImpl.checkNotClosed(PlainSocketImpl.java:116)?

我与Android套接字工作,并不断收到此错误为什么会出现此错误:java.net.PlainSocketImpl.checkNotClosed(PlainSocketImpl.java:116)?

的logcat:


[xiaomi-mi_4i-a98ed4b2]: E/File couldn't be stored: java.net.PlainSocketImpl.checkNotClosed(PlainSocketImpl.java:116) 

[xiaomi-mi_4i-a98ed4b2]: W/System.err: java.net.SocketException: Socket is closed

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at java.net.PlainSocketImpl.checkNotClosed(PlainSocketImpl.java:116)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at java.net.PlainSocketImpl.getInputStream(PlainSocketImpl.java:213)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at java.net.Socket.getInputStream(Socket.java:363)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at com.rkp.musictest1.wifi.datatransfer.WifiSocket.receiveFileSocket(WifiSocket.java:264)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at com.rkp.musictest1.wifi.datatransfer.WifiSocket$4.run(WifiSocket.java:249)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at com.rkp.musictest1.wifi.datatransfer.SimpleAsynTask$simpleTask.doInBackground(SimpleAsynTask.java:65)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at com.rkp.musictest1.wifi.datatransfer.SimpleAsynTask$simpleTask.doInBackground(SimpleAsynTask.java:23)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

[xiaomi-mi_4i-a98ed4b2]: W/System.err: at java.lang.Thread.run(Thread.java:818)

回答:

你可以看看到源代码自己 - 这是enter link description here:

private void More ...checkNotClosed() throws IOException { 

if (!fd.valid()) {

throw new SocketException("Socket is closed");

}

}

fd是一个FileDescriptor;并为此我们找到;关于有效()方法:

返回: 如果真文件描述符对象表示一个有效的,打开文件,插座,或其他活动的I/O连接;否则为假。

因此,长话短说:有些东西是封闭的,不应该关闭。但进一步调试是没有看到导致此错误的代码/活动。

希望这足以让你现在就去!

以上是 为什么会出现此错误:java.net.PlainSocketImpl.checkNotClosed(PlainSocketImpl.java:116)? 的全部内容, 来源链接: utcz.com/qa/266672.html

回到顶部