/// <summary>
        /// Method to execute the broadcast
        /// </summary>
        /// <param name="client">the udp client</param>
        /// <param name="broadcast">The broadcast to send to the client.</param>
        private async Task BroadcastAsync(UdpClient client, UpnpBroadcast broadcast)
        {
            int broadcasts = 0;

            do
            {
                await client.SendAsync(broadcast.Content, broadcast.ContentLenght, broadcast.IpEndPoint);

                broadcasts++;

                await Task.Delay(TimeSpan.FromSeconds(2));
            } while (broadcasts < 5);
        }
        private async Task BeginSendReceiveAsync(IPAddress broadcastAddress, Action <FritzDevice> callback)
        {
            using (UdpClient client = new UdpClient(broadcastAddress.AddressFamily))
            {
                List <Task> receivebroadcast = new List <Task>();
                client.MulticastLoopback = false;
                Socket socket = client.Client;


                var broadcastViaIpV4 = broadcastAddress.AddressFamily == AddressFamily.InterNetwork;

                if (broadcastViaIpV4)
                {
                    socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, broadcastAddress.GetAddressBytes());
                }
                else
                {
                    byte[] interfaceArray = BitConverter.GetBytes((int)broadcastAddress.ScopeId);

                    var mcastOption = new IPv6MulticastOption(broadcastAddress, broadcastAddress.ScopeId);
                    socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.MulticastInterface, interfaceArray);
                }

                socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                socket.ReceiveBufferSize   = Int32.MaxValue;
                client.ExclusiveAddressUse = false;
                socket.Bind(new IPEndPoint(broadcastAddress, 1901));

                var broadCast = broadcastViaIpV4 ? UpnpBroadcast.CreateIpV4Broadcast() : UpnpBroadcast.CreateIpV6Broadcast();
                if (broadcastViaIpV4)
                {
                    socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(broadCast.IpAdress));
                }
                else
                {
                    socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.AddMembership, new IPv6MulticastOption(broadCast.IpAdress, broadcastAddress.ScopeId));
                }

                await Task.WhenAll(
                    this.ReceiveAsync(client, callback),
                    this.BroadcastAsync(client, broadCast)
                    );
            }
        }