title: C# UDP Multicast with multiple clients - only receiving message from one client
body: <p>So I have created a simple UDP server that broadcasts a datagram to clients via multicast. Upon receiving this message, each client responds by sending a multicast datagram reporting some internal state.</p>
  
  <p>Only the server is interested in the message sent by the clients, although the clients and servers all use the same UDP send/receive code.</p>
  
  <p>My issue is that with multiple clients I only ever seem to receive a datagram from one client. The other client's messages are never received even though they are sent.</p>
  
  <p>I am using Microsoft's UdpClient and listening for messages on a separate thread using UdpClient.Receive(IPEndpoint endpoint).</p>
  
  <p>My UdpClient is initialised as follows:</p>
  
  <pre><code>_ipEndpoint = new IPEndpoint(ipAddress, port);
  _udpClient = new UdpClient(port, ipAddress.AddressFamily) { MulticastLoopback = false, DontFragment = true };
  _udpClient.JoinMulticastGroup(ipAddress);
  </code></pre>
  
  <p>Listening is as follows, called within a while loop on a separate thread:</p>
  
  <pre><code>public bool ReceiveMessage(out BaseMessage message)
  {
      try
      {
          byte[] dataBuffer = _udpClient.Receive(ref _ipEndpoint); 
          message = UdpSerializer.ByteArrayToObject(dataBuffer);
      }
      ...
  </code></pre>
  
  <p>Any ideas?    </p>