createUdpSocket method
Implementation
Future<void> createUdpSocket(String host, int port) async {
try {
_udpSocket = await RawDatagramSocket.bind(host, port);
_udpSocket?.listen(
(RawSocketEvent event) {
if (event == RawSocketEvent.read) {
final datagram = _udpSocket?.receive();
if (datagram != null) {
final message = String.fromCharCodes(datagram.data);
}
}
},
onError: (error) {},
onDone: () {},
);
} catch (e) {}
}