socket.isClosed remains `false` after socket.close() call
See original GitHub issueHi, I’m using io.ktor:ktor-network-tls:1.0.1
[1], running JDK8 on MacOSX 10.10.5
The minimal working example to reproduce the problem is as follows:
import io.ktor.network.selector.ActorSelectorManager
import io.ktor.network.sockets.aSocket
import io.ktor.network.sockets.isClosed
import io.ktor.network.sockets.openReadChannel
import io.ktor.network.sockets.openWriteChannel
import kotlinx.coroutines.Dispatchers.Unconfined
import kotlinx.coroutines.newSingleThreadContext
import kotlinx.coroutines.runBlocking
/** Created by revin(caoyunbin@baidu.com) on 2018-12-26. */
fun main(args:Array<String>)=runBlocking(Unconfined){
val tcp=aSocket(ActorSelectorManager(newSingleThreadContext("httpIO"))).tcp()
val socket=tcp.connect("www.baidu.com",80)
socket.openReadChannel();socket.openWriteChannel()
socket.close();println(socket.isClosed)
}
The result expected from the above code is true
but instead I got false
- I can’t use
io.ktor:ktor-network-tls:1.1.0
, which is the latest version as of writing. The following error shows up when trying to build the project. So I’m using an earlier version to report the problem
CONFIGURE FAILED in 7s
Could not find org.jetbrains.kotlinx:atomicfu:0.12.0.
Searched in the following locations:
https://repo1.maven.org/maven2/org/jetbrains/kotlinx/atomicfu/0.12.0/atomicfu-0.12.0.pom
https://repo1.maven.org/maven2/org/jetbrains/kotlinx/atomicfu/0.12.0/atomicfu-0.12.0.jar
Required by:
project :jvm > io.ktor:ktor-network-tls:1.1.0
project :jvm > io.ktor:ktor-network-tls:1.1.0 > org.jetbrains.kotlinx:kotlinx-io-jvm:0.1.2
project :jvm > io.ktor:ktor-network-tls:1.1.0 > org.jetbrains.kotlinx:kotlinx-coroutines-io-jvm:0.1.2
project :jvm > io.ktor:ktor-network-tls:1.1.0 > io.ktor:ktor-network:1.1.0
- According to maven(https://mvnrepository.com/artifact/io.ktor/ktor-network-tls/1.1.0), ktor-network-tls relies on ktor-http-cio-native, is that intentional?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
java - Socket isClosed() returns false after client disconnected
The system call then returns no error but 0 bytes and this means that there will be no more data from the peer....
Read more >The program not closed after socket.close() · Issue #85 - GitHub
After pressing 'q' socket call close() but programm still working. I look at debugger and find there EventThread in runnable state.
Read more >socket bind throws socket closed — oracle-tech
isClosed () what the javadoc should say: Indicates if close() has been called on this socket. Initially this method returns false. After Socket.close()...
Read more >In Java, what happend to socket on server side (not ... - Quora
Socket.isConnected() is still true and Socket.isClosed() is still false. ... the server will unbind the client but the server connection will not be...
Read more >no IOException on socket read/write after remote close ...
closed. Once again, the socket's state both before and after the write, is ... thread 1 stays blocked inside the readByte() call and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Cannot reproduce with Ktor 1.6.1.