title: Send broadcast with unknown port
body: <p>Is it possible, to send a broadcast for searching a server application, if i don't know the port on which the server is running? Or do i have to check every port?</p>
  
  <p>To send a simple broadcast, i found the following code at the internet:</p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
  Console.Write("Running server..." + Environment.NewLine);
  server.Bind(new IPEndPoint(IPAddress.Any, 48000));
  
  while (true)
  {
      IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
      EndPoint tempRemoteEP = (EndPoint)sender;
      byte[] buffer = new byte[1000];
  
      server.ReceiveFrom(buffer, ref tempRemoteEP);
  
      Console.Write("Server got '" + buffer[0] + "' from " + tempRemoteEP.ToString() + Environment.NewLine);
  
      Console.Write("Sending '2' to " + tempRemoteEP.ToString() +
      Environment.NewLine);
  
      server.SendTo(new byte[] { 2 },
      tempRemoteEP);
  }
  </code></pre>
  
  <p><strong>Client</strong></p>
  
  <pre><code>Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
  
  IPEndPoint AllEndPoint = new IPEndPoint(IPAddress.Broadcast, 48000);
  
  //Allow sending broadcast messages
  client.SetSocketOption(SocketOptionLevel.Socket,
  SocketOptionName.Broadcast, 1);
  
  //Send message to everyone
  client.SendTo(new byte[] { 1 }, AllEndPoint);
  Console.Write("Client send '1' to " + AllEndPoint.ToString() +
  Environment.NewLine);
  
  IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
  EndPoint tempRemoteEP = (EndPoint)sender;
  byte[] buffer = new byte[1000];
  
  string serverIp;
  
  try
  {
      //Recieve from server. Don't wait more than 3000 milliseconds.
      client.SetSocketOption(SocketOptionLevel.Socket,
      SocketOptionName.ReceiveTimeout, 3000);
      client.ReceiveFrom(buffer, ref tempRemoteEP);
      Console.Write("Client got '" + buffer[0] + "' from " +
      tempRemoteEP.ToString() + Environment.NewLine);
  
      //Get server IP (ugly)
      serverIp = tempRemoteEP.ToString().Split(":".ToCharArray(), 2)[0];
  }
  catch
  {
      //Timout. No server answered.
      serverIp = "?";
  }
  
  Console.Write("ServerIp: " + serverIp + Environment.NewLine);
  Console.ReadLine();
  </code></pre>
  
  <p>But I don't know, wehter my server use port <code>48000</code>.</p>