Search code examples
androidnetwork-programmingudpmqttudpclient

To write chat programming using UDP and MQTT protocol in Android


I am new in Android programming and don't know how to work with UDP and MQTT protocol in android device

I want to build an application for chatting android to android device within room connected to same Wi-Fi router.

But I don't know what IP address and port I should bind to DatagramSocket and DatagramPacket.

I tried lot of examples from online but I didn't understand how it will work in android.


Solution

  • MQTT requires TCP, it is a statefull protocol, you can not implement it with UDP

    There is a similar protocol called MQTT-SN which can be implemented with a stateless protocol like UDP.

    But both of these are still going to require a broker running somewhere to coordinate the delivery of messages to subscribers to given topics