public async void Stop() { if (!connected) { return; } await receiver.DisconnectAsync(); receiver.Dispose(); await sender.DisconnectAsync(); sender.Dispose(); connected = false; }
public async Task sendBroadcastUdp(string message, int port = 1234) { byte[] data = Encoding.UTF8.GetBytes(message); string address = "255.255.255.255"; try { var uc = new UdpSocketClient(); await uc.SendToAsync(data, address, port); uc.Dispose(); Debug.WriteLine("UDP: Sent {0} to {1}:{2}", message, address, port); } catch (Exception e) { Debug.WriteLine(e.Message); } }