title: Does broadcasting over UDP repeatedly send its packet, or just once?
body: <p>Using C#, does broadcasting over UDP repeatedly send its packet, or just once?</p>
  
  <p>I've never used this technology before and I want to temporarily broadcast small bit of info (a small one line string) over the LAN. If the receiving end isn't ready will the broadcast repeat itself or was it a one time thing? The code I'm using is from <a href="http://blog.eviac.com/2010/12/network-broadcasting-with-c.html" rel="nofollow">here</a>. So what I want to start the Broadcaster one one machine and a few minutes later start the receiver and retrieve what the broadcaster sent.</p>
  
  <p>Here is the code </p>
  
  <pre><code>using System;  
  using System.Net;  
  using System.Net.Sockets;  
  using System.Text;  
  class Broadcst  
  {  
    public static void Main()  
    {  
     Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,  
                  ProtocolType.Udp);  
     IPEndPoint iep1 = new IPEndPoint(IPAddress.Broadcast, 9050);  
     IPEndPoint iep2 = new IPEndPoint(IPAddress.Parse("192.168.1.255"), 9050);  
     string hostname = Dns.GetHostName();  
     byte[] data = Encoding.ASCII.GetBytes(hostname);  
     sock.SetSocketOption(SocketOptionLevel.Socket,SocketOptionName.Broadcast, 1);  
     sock.SendTo(data, iep1);  
     sock.SendTo(data, iep2);  
     sock.Close();  
    }  
  }  
  </code></pre>