MultiCast send and receive on same XP machine?

  • Thread starter Alfred B. Thordarson
  • Start date
A

Alfred B. Thordarson

Hi All.

I have this weird problem that on my devlepment machine (Windows XP) I
don't receive MultiCast messages that I send from my machine. This
means that my two processes can't communicate using MultiCast if they
both run on the same machine.

I have created a small MultiCast "server" which is listening for
messages on 224.100.0.1:8932 and then a small MultiCast "client" that
sends out messages to this same address and port. The two work well
(the server displays the messages sent by the client) if the two are
running on separate machines.

However, if I run them both on my development machine the server
receives nothing? What am I missing? Your input would be highly
appreciated as I don't seem to be able to crack this one.

The important part of the listening "server" is:

---
IPAddress multiCastAddress = IPAddress.Parse("224.100.0.1");
int multiCastPort = 8932;

IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress localMultiCastAddress=ipHostInfo.AddressList[0];

IPEndPoint localMultiCastPoint = new IPEndPoint(localMultiCastAddress,
multiCastPort);

multiCastSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);

multiCastSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress,1);

multiCastSocket.Bind(localMultiCastPoint);

MulticastOption multicastOption = new
MulticastOption(multiCastAddress,

localMultiCastAddress);

multiCastSocket.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership,
multicastOption);

multiCastSocket.BeginReceive(buffer, 0, 10240, 0,
new
AsyncCallback(Server.MessageReceived),
null);
---

The important part of the sending "client" is:

---
IPAddress multiCastAddress = IPAddress.Parse("224.100.0.1");
int multiCastPort = 8932;

IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress localMultiCastAddress=ipHostInfo.AddressList[0];

multiCastSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);

MulticastOption multicastOption = new
MulticastOption(multiCastAddress,
localMultiCastAddress);

multiCastSocket.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership,
multicastOption);

IPEndPoint multiCastEndPoint = new
IPEndPoint(multiCastAddress,multiCastPort);

while(true)
{
string msg="Message at "+DateTime.Now.Ticks.ToString();
multiCastSocket.SendTo(Encoding.ASCII.GetBytes(msg),multiCastEndPoint);
Console.WriteLine("Sent message ["+msg+"] to "+multiCastAddress
.ToString()+":"+multiCastPort+"...");
Thread.Sleep(1000);
}

---

When composing this message I tried running both on the same machine
(but now on a different XP machine - not on my development machine)
and it seems to work there (and my development machine receives the
messages as well). But still doesn't work if I run both on my
development machine. Wonder if this is a Windows XP configuration
problem?

I would really like your input on this – I'm completely stuck and I'm
sure you can help me with this.

-Alfred
 
A

Alfred B. Thordarson

I don't think this is in my code because now I have tried the same
thing using the samples that come with Visual Studio .NET 2003 for
MultiCastOption and they work together on other machines as well as
between machines. But not even those samples work running together
both on my development machine.

This is some configuration on my machine. Do you have any thoughts on
what configuration that could be? I have been looking over the network
configuration and can't see a difference between my development
machine and the other machines that the two samples work on?!?

Looking forward to hearing from you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top