"PHLICS_Admin" <ph****@hotmail.com> wrote in message news:<uQ*************@tk2msftngp13.phx.gbl>...
Hi All,
Following code is used to set multicast interface :
IPAddress ipLan = IPAddress.Parse("...");
int iIP = (int)(ipLan.Address) ;
objMCastSender.SetSocketOption(SocketOptionLevel.I P,SocketOptionName.Multica
stInterface , iIP) ;
Would you please give me some advise about how to solve it .
Phlics -
You don't need to convert the IP address to an int for it to work.
You can use the GetAddressBytes() IPAddress method, and then use that
value for the SetSocketOption() method. This worked fine on my PC:
Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
IPAddress ipLan = IPAddress.Parse("192.168.1.10");
byte[] bIP = ipLan.GetAddressBytes();
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastInterface,
bIP);
IPEndPoint iep = new IPEndPoint(IPAddress.Parse("224.100.0.1"),
9050);
byte[] data = Encoding.ASCII.GetBytes("This is a test");
sock.SendTo(data, iep);
sock.Close();
Hope this helps shed some light on your problem.
Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html