Android Tutorial MQTT Chat with Auto Discovery

Discussion in 'Tutorials & Examples' started by Erel, Jan 30, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    This is an extension to the MQTT chat room example:
    It is a chat room where one of the devices acts as a server and the others as clients.


    The difference in this example is that the clients don't need to enter the server ip address.
    All devices listen to UDP packets on port 51049.
    The server broadcasts its ip address every second. It is done by sending a UDP packet to the broadcast address.
    The result is that any device listening on the correct port will receive the message.
    The "Connect As Client" button will be enabled when the server ip address is discovered (and the name field is not empty).

    Finding the broadcast address:
    B4J / B4i: UDPSocket.GetBroadcastAddress

    Note that it can take a few seconds before the broadcast message arrives.

    Attached Files:

    Last edited: Jan 30, 2017
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice