title: C# Broadcasting message on server to remote client
body: <p>I'm trying to broadcast a message from server to a remote client, my problem is that I'm not able to receive the message on the client, the approach I'm currently playing with is as follows:</p>
  <pre><code>//Server 
  UdpClient udpServer = new UdpClient();
  udpServer.Client.Bind(new IPEndPoint(IPAddress.Any, port));
  var send = Task.Run(() =&gt;
  {
      var to = new IPEndPoint(IPAddress.Broadcast, port);
      while (true)
      {
          var response = gameWorld.GetStateJson();
          var responseInBytes = Encoding.ASCII.GetBytes(response);
          udpServer.SendAsync(responseInBytes, responseInBytes.Length, to);
          Console.WriteLine(response);
          gameWorld.Update();
      }
  });
  send.Wait();
  </code></pre>
  <p>And for the client:</p>
  <pre><code>//Client
  UdpClient receivingUdpClient = new UdpClient(8081);
  while (true)
  {
      IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Parse(&quot;11.111.111.111&quot;), 0);
      try
      {
          byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
  
          string returnData = Encoding.ASCII.GetString(receiveBytes);
  
          Console.WriteLine(returnData.ToString());
      }
      catch (Exception e)
      {
          Console.WriteLine(e.ToString());
      }
  }
  </code></pre>
  <p>So the current client code works as expected, but only for my LAN (if I understand correctly), I'm not sure what should I change in order to be receiving the messages over the  internet &quot;globally&quot;, advice would be highly appreciated.</p>
  <p>Side question: does the server code as is broadcast the data &quot;globally&quot; ? Or is it also for my LAN only?</p>
  <p><strong>EDIT: Is this somehow possible or do I have to send data to each client explicitly, even though they're the same for all</strong></p>