title: Am I well connected to UDP Multicast? C#
body: <p>I have this code, but I don't know if I am well connected or joined to the multicast group. I can send and receive messages through the normal IP &quot;ip&quot;. But I don't know if I should do anything more to receive messages through multicast. I have this code:</p>
  <pre><code>    public void UDPConnect()
      {
          socket = new UdpClient(25504); 
          try
          {
              endPoint = new IPEndPoint(IPAddress.Parse(ip), 2600);
             
              socket.JoinMulticastGroup(IPAddress.Parse(multicastIP));
              socket.Connect(endPoint); 
              
              byte[] sendBytes = Encoding.ASCII.GetBytes(&quot;Hello, from the client&quot;);
              socket.Send(sendBytes, sendBytes.Length);
  
              ConnectToServer();
          }
          catch (Exception e)
          {
              print(&quot;Exception thrown &quot; + e.Message);
          }
      }
  
      public void ConnectToServer()
      {
          InitializeClientData();
  
          isConnected = true;
          StartCoroutine(ClientSend.VisualStartupCor()); 
  
          socket.BeginReceive(ReceiveCallback, null);
      }
  
      public void ReceiveCallback(IAsyncResult _result)
      {
          try
          {
              byte[] _data = socket.EndReceive(_result, ref endPoint);
              socket.BeginReceive(ReceiveCallback, null);
             
              if (_data.Length &lt; 4)
              {
                  Instance.Disconnect();
                  return;
              }
  
              HandleData(_data);
          }
          catch
          {
              Disconnect();
          }
      }
  </code></pre>
  <p>And this is my server code, just too simple. I just wanna to test if I can send and receive for the Client. As you can see, I have put the multicast IP that I use (231.1.1.10) in the Send method. When I send a message from the client, this server answers by sending the same message to the client. My client, in Unity, detects this message. It means that the multicast connection is successful?</p>
  <pre><code>var udp = require('dgram');
  
  // --------------------creating a udp server --------------------
  
  // creating a udp server
  var server = udp.createSocket('udp4');
  
  // emits when any error occurs
  server.on('error',function(error){
  console.log('Error: ' + error);
  server.close();
  });
  
  // emits on new datagram msg
  server.on('message',function(msg,info){
  console.log('Data received from client : ' + msg.toString());
  console.log('Received %d bytes from %s:%d\n',msg.length, info.address, info.port);
  
  //sending msg
  
  server.send(msg,info.port,'231.1.1.10',function(error){
  if(error){
  client.close();
  }else{
  console.log('Data sent !!!');
  }
  
  });
  });
  
  //emits when socket is ready and listening for datagram msgs
  server.on('listening',function(){
  var address = server.address();
  var port = address.port;
  var family = address.family;
  var ipaddr = '192.XXX.X.XX';
  console.log('Server is listening at port' + port);
  console.log('Server ip :' + ipaddr);
  console.log('Server is IP4/IP6 : ' + family);
  console.log(address);
  });
  
  //emits after the socket is closed using socket.close();
  server.on('close',function(){
  console.log('Socket is closed !');
  });
  
  server.bind(2600);
  </code></pre>