473,375 Members | 1,669 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,375 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 5612
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.