473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Multicast on only one of two networks

I have a computer with two network cards (attached to seperate networks) and
I am having trouble getting my C# application to send its multicast packets
on a specific one. It receives just fine (I'm assuming because its listening
to both networks), but it seems like it just picks the default to send over.

I have implemented the MulticastOption(RemoteIP, LocalIP), but it doesn't
seem to be changing the interface it sends over.

Here's some of my code:
public void setupSocket()
{
localEP = new IPEndPoint(localIP, localPort);
incomingEP = new IPEndPoint(IPAddress.Any, 0);

sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
sock.Bind((EndPoint)localEP);
if(multicast)
{
mcEP = new IPEndPoint(mcIP, localPort);
MulticastOption mcastOption = new MulticastOption(mcIP, localIP);
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership, mcastOption);
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 2);
//sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastInterface, <??? What goes here, its listed as a
byte []. but what is its value!???>);

//sock.Connect(mcEP); // Doesn't work in multicast, use sendto()
}
else
{
remoteEP = new IPEndPoint(remoteIP, remotePort);
sock.Connect(remoteEP);
}
}
public void receive()
{
EndPoint inEP = (EndPoint)incomingEP;
Byte[] buffer = new Byte[1024];
int size = sock.ReceiveFrom(buffer, ref inEP);
}
public void send(Byte[] buffer)
{
// if multicast
if(mcEP != null)
{
//client.Send(buffer, buffer.Length, mcEP);
//sock.Send(buffer);
sock.SendTo(buffer, mcEP);
}
else
{
sock.Send(buffer);
}
}
In addition, it seems to send O.K. when I send unicast. It doesn't work
when I try to do sock.connect(...) while using multicast. Any help would be
much appreciated! Thanks!

Nov 16 '05 #1
6 5615
Hi teeks,
. Regarding on the issue, I am
finding proper resource to assist you and we will update as soon as posible.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)

Nov 16 '05 #2
Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you are having trouble to send data
over a particular network adapter. If there is any misunderstanding, please
feel free to let me know.

Based on my research, this issue might be caused by incorrect binding to
network adapters. When a Socket is binded to an IP address of Any or 0 as
value, it will select the network adapter automatically. By default, it
chooses the default one to send over. That might be the point you're
suffering from.

So please check localEP objected to see the value passed in. It shouldn't
be 0 or something like 127.0.0.1.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3
You are correct. As far as I can tell the problem is in sending data over a
particular network adapter.

I have verified that the localIP that I start with is correct for the
particular network I wish to use, (the Address and m_Address values are both
0x14B3E05). This continues when I create the localEP. It also continues
when I cast it to an EndPoint and bind to the sock
(sock.LocalEndPoint.Adddress and sock.m_LocalEndPoint.Address, etc).

Nothing much has changed in all this.

Do I need to do anythign with the SetSocketOption(... ,
SocketOptionName.MulticastInterface, ...). I can't figure out what the third
argument should be if I do need it. Thanks!
"Kevin Yu [MSFT]" wrote:
Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you are having trouble to send data
over a particular network adapter. If there is any misunderstanding, please
feel free to let me know.

Based on my research, this issue might be caused by incorrect binding to
network adapters. When a Socket is binded to an IP address of Any or 0 as
value, it will select the network adapter automatically. By default, it
chooses the default one to send over. That might be the point you're
suffering from.

So please check localEP objected to see the value passed in. It shouldn't
be 0 or something like 127.0.0.1.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #4
Hi,

If you're trying to Multicast, I think you have to use SetSocketOption
method. Please check the following link for more information.

http://support.microsoft.com/?id=318911

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #5
Yeah, I've seen that example. I don't know what index is though. All I can
find out is that it's a byte array. Is it a string like "1.75.81.5" or is it
index[0] = 1, index[1] = 75, index[2] = 81, index[3] = 5, or is it something
like "Local Area Connection 2"???

Thanks for your help so far :-)

"Kevin Yu [MSFT]" wrote:
Hi,

If you're trying to Multicast, I think you have to use SetSocketOption
method. Please check the following link for more information.

http://support.microsoft.com/?id=318911

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #6
Hi,

Since SetSocketOption method has several overloads, the optionValue can be
an int, a byte array or an object like MulticastOption object. It can also
be a value from converted by IPAddress.HostToNetworkOrder and depends on
the option you need to set. But there is no overload which accepts a string.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ron Vecchi | last post by:
I have been given a task to reasearch multicasting, specifically with the transmission of streaming media. I honestly have no clue about what multicating is and more so how or when to implement...
2
by: Jim H | last post by:
Is there something special I need to do to send data to a multicast IP and have it go across a router? Router is a Win2000 Server connecting 2 networks via RRAS PPTP. The routing appears to be...
5
by: GVN | last post by:
Hi All, I recently worked on delegates. But I have a question regarding Multicast delegates. The scenario is as follows: I have a delegate myDelegate with object dlgt, and two methods...
7
by: pietro.cerutti | last post by:
Hi guys, I have a daemon running on Debian and listening for multicast packets sent to 224.0.0.251:5353 (ZeroConf Multicast DNS queries). The server is plugged into a VLAN trunk with eth0 and...
1
by: Jayme.Pechan | last post by:
I was working on a multicast client and ran into a possible problem. Here is the code... udpClient = new UdpClient(4000); udpClient.JoinMulticastGroup(IPAddress.Parse("224.1.1.1"));...
1
by: satya0674 | last post by:
Hi Everybody , Is any one have the soft copy of the book Developing IP Multicast Networks: The Definitive Guide to Designing and Deploying CISCO IP Multi- cast Networks by Beau...
5
by: AliRezaGoogle | last post by:
Hi, I have a conceptual question on Events and Multicast Delegates. Let me explain: As we know an event is a multicast delegate. What we declare as an event is inherently a multicast delegate....
0
by: Stodge | last post by:
I'm trying to get a simple multicast application working using Twisted; so far I have: from twisted.internet.protocol import DatagramProtocol from twisted.internet import reactor from...
9
by: raylopez99 | last post by:
Hello all— I’m trying to get the below to work and cannot get the format right. It’s from this example: http://msdn.microsoft.com/en-us/library/8627sbea(VS.71).aspx What it is: I’m trying...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.