Running UDP Sender/Receiver Android APP on ChromeOS

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Jun 4, 2019, 12:49:02 PM via Website

I'm working on application that uses UDP Sender/Receiver functionality to broadcast current machine ip address to 255.255.255.255 address. In response UDP server gives response from other device (Payment terminal in my case) ip address. On Android based devices like tablet or phone it is working as expected. Problem starts with ChromeOS computer. I broadcast information but on the second machine with WireShark running there is no result. I know that apps running on ChromeOS are behind some firewall and they do not have straight access to WiFi device. The only solution is to use Android Network Service Discovery but I do not know how to use it in this scenario. Below I paste UDP sender code that works everywhere except ChromeOS

    fun sendDatagramPacketSender(
        bytePacketToSend: ByteArray,
        targetIP: String,
        targetPort: Int
): Completable {
    return fromAction {
        try {
            val datagramPacket =
                    DatagramPacket(bytePacketToSend, bytePacketToSend.size, InetAddress.getByName(targetIP), targetPort)

            mDatagramSocket.send(datagramPacket)
        } catch (e: Exception) {
            Log.e(TAG, e.message)
        }
    }
}

Do you have any other solution for my problem or example of using NSD in my case?

Be the first to answer