I’m having an issue with a specific device (a Samsung Galaxy A54, but one specific one).
I’m trying to connect to a socket, while not in the same network (the ip address isn’t even pingable), which I’m expecting to either timeout, or at least throw another exception.
Instead, it just returns, and socket.isConnected
even returns true.
@Throws(IOException::class)
private fun openSocket(address: InetSocketAddress): Boolean {
val socket = createSocket()
return try {
socket.connect(address, 2500)
this.socket = socket
socket.isConnected
} catch (e: ConnectException) {
e.printStackTrace()
false
} catch (e: SocketTimeoutException) {
e.printStackTrace()
false
}
catch (e: Exception) {
e.printStackTrace()
false
}
}
I’ve tried this on different devices (including another Galaxy A54), where it does behave as expected.
I’ve also tried changing
socket.isConnected
to socket.isConnected && !socket.isClosed
, but it still returns true.