public void send_multicast(string message)
{
UdpClient c = new UdpClient(10102);
Byte[] sendBytes = Encoding.ASCII.GetBytes(message);
IPAddress m_GrpAddr = IPAddress.Parse("224.0.0.1");
IPEndPoint ep = new IPEndPoint(m_GrpAddr,10102);
c.MulticastLoopback=true;
c.JoinMulticastGroup(m_GrpAddr);
c.Send(sendBytes,sendBytes.Length,ep);
Console.WriteLine(message);
}
public string recv_multicast()
{
Console.WriteLine("was here");
String strData = "";
//String Ret = "";
ASCIIEncoding ASCII = new ASCIIEncoding();
UdpClient c = new UdpClient(10101);
// Establish the communication endpoint.
IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, 10101);
IPAddress m_GrpAddr = IPAddress.Parse("224.0.0.1");
c.JoinMulticastGroup(m_GrpAddr);
Byte[] data = c.Receive(ref endpoint);
strData = ASCII.GetString(data);
//Ret += strData + "\n";
return strData;
}
is there anything wrong with the ports?
the recv method is getting blocked but is not receiving the message?
In wireshark I can see the message going from local addr port 10102 to 224.0.0.1 dest_port 0, but the recv is not getting the msg from the multicast addr.
BTW I am running both instances on the same computer. reference : http://msdn.microsoft.com/en-us/library/ekd1t784.aspx
**Got the solution:In send routine
IPEndPoint ep = new IPEndPoint(m_GrpAddr,10102);
should be
IPEndPoint ep = new IPEndPoint(m_GrpAddr,10101);
the port of receiving**