Suitable for Dart's LAN multicast + broadcast implementation of message sending and receiving.
In the Android hotspot, when the PC side is connected, there will be a delay in the PC side detecting the Android side UDP message, depending on the LAN. To put it simply, the latency of PC-side monitoring Android is higher than that of Android-side monitoring PC.
Currently, device discovery is achieved through multicast and broadcast .
After trying multicast_dns, the example code did not get through. This is the information in the process of lying down: flutter/flutter#16335
Android turns off multicast by default, which means that the Android device cannot receive the multicast messages sent by other devices on the LAN. This problem has been solved through the internal plugin. The current problems are: Open the hotspot on the Android device and connect to the PC In this case, the PC device cannot receive the multicast message from the Android device, so the code for monitoring UDP supports both multicast and broadcast. Sending UDP also sends the message to the multicast address and broadcast address at the same time.