Which would be the right way to make a TCP request using Socket in kotlin by using CoroutineScope?
by using GlobalScope.async the call works properly but i get the inspector errors on socket which says:  Inappropriate blocking method call
The socket call should be done from a handler function and i was trying to do it by using Coroutine IO but when i try to run it i get the error:
FATAL EXCEPTION: DefaultDispatcher-worker-1
Here is my code:
private fun handlePhoneCall(
    response: CallResponse.Builder,
    phoneNumber: String
): CallResponse.Builder {
    val ipCassa = PreferenceManager.getDefaultSharedPreferences(this).getString("server", "127.0.0.1")
    GlobalScope.launch(IO) {
        Socket(ipCassa, 50000).use { socket: Socket ->
            val outputStream = socket.getOutputStream()
            outputStream.write(data.toByteArray())
            outputStream.flush()
        }.runCatching {
        }.onFailure {
            Log.e("SOCKET", it.message.toString())
        }
    }
    return response
}
 
    