0
0k
Hi everyone, I am trying to write a small app that sends multicast udp
packets using a socket object.
I have more than one NIC on my PC and the following code works OK only if I
disable all the NICs but the one i want to use.
Of course i tried to use Socket.Bind method, but even if i use it to bind to
the correct NIC (I also verify using LocalEndPoint and IT IS the correct
one), the packet is sent on the wrong NIC! (I have a software firewall that
tells me the source NIC). What is really weird is that after executing the
first setsocketoption the program broadcasts to 224.0.0.22, WHY??? The group
is 224.5.6.7!
Can someone help me, i'm going nuts on this problem!
The code i use to send the packet is next, thanx to anyone answering!!!
UdpSender = New Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp)
WITH OR WITHOUT THIS IT IS THE SAME!!!!
UdpSender.Bind(New IPEndPoint(IPAddress.Parse("192.168.0.1"), 5000))
With UdpSender
.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership, New
MulticastOption(IPAddress.parse("224.5.6.7")))
.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 1)
End With
groupEP = New IPEndPoint(IPAddress.Parse("224.5.6.7"), 5000)
bytes = Encoding.ASCII.GetBytes(message)
UdpSender.Connect(groupEP)
UdpSender.Send(bytes, bytes.Length, SocketFlags.None)
UdpSender.Close()
packets using a socket object.
I have more than one NIC on my PC and the following code works OK only if I
disable all the NICs but the one i want to use.
Of course i tried to use Socket.Bind method, but even if i use it to bind to
the correct NIC (I also verify using LocalEndPoint and IT IS the correct
one), the packet is sent on the wrong NIC! (I have a software firewall that
tells me the source NIC). What is really weird is that after executing the
first setsocketoption the program broadcasts to 224.0.0.22, WHY??? The group
is 224.5.6.7!
Can someone help me, i'm going nuts on this problem!
The code i use to send the packet is next, thanx to anyone answering!!!
UdpSender = New Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp)
WITH OR WITHOUT THIS IT IS THE SAME!!!!
UdpSender.Bind(New IPEndPoint(IPAddress.Parse("192.168.0.1"), 5000))
With UdpSender
.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership, New
MulticastOption(IPAddress.parse("224.5.6.7")))
.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 1)
End With
groupEP = New IPEndPoint(IPAddress.Parse("224.5.6.7"), 5000)
bytes = Encoding.ASCII.GetBytes(message)
UdpSender.Connect(groupEP)
UdpSender.Send(bytes, bytes.Length, SocketFlags.None)
UdpSender.Close()