473,563 Members | 2,667 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use ReceiveFrom to capture multicast data

The MSDN says that I have to bind the socket on a local address to use
ReceiveFrom function. How can I bind the socket on a multicast address
in order to get the multicast data.
Say that I want to receive data that is sent from 10.154.0.104:55 4 to
224.1.2.3:554.
How can I get the data at 224.1.2.3:554 since this is a multicast
address, and using ReceiveFrom? Where do I bind my socket (I have to
bind it to a local IP otherwise gives invalid address)?

Thanks.

--------------------------

Here's a simple code that blocks:

public MulticastServer (int localPort)
{
socket=new
Socket(AddressF amily.InterNetw ork,SocketType. Dgram,ProtocolT ype.Udp);
IPHostEntry IPHost=Dns.GetH ostByName(Dns.G etHostName());
IPAddress ip=IPAddress.Pa rse(IPHost.Addr essList[0].ToString());
IPEndPoint ep=new IPEndPoint(ip,l ocalPort);
socket.Bind(ep) ;
}

public byte[] ReceiveFrom(str ing ipAddress,int port)
{
//if(socket.Avail able==0)return null;
IPEndPoint ep=new IPEndPoint(IPAd dress.Any,0);
EndPoint ep2=(EndPoint)e p;
byte[] buffer=new byte[1500];
int receivedBytes=s ocket.ReceiveFr om(buffer,ref ep2);
byte[] packet=new byte[receivedBytes];
Array.Copy(buff er,0,packet,0,r eceivedBytes);
return packet;
}

Jan 17 '06 #1
0 1611

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

Similar topics

0
277
by: Frustrated | last post by:
I have an application that we are porting from Unmanaged C++ to VB.NET that involves sockets. There are two pieces to the code. One piece is a one to one TCP call to a server which is working fine. The second piece receives streaming data from the server on a regular basis via UDP. My problem is that I can not make the ReceiveFrom call...
3
2403
by: Fred Palmer | last post by:
I am trying to get reponses from multiple devices on my network by sending the following message via UDP: // Create the message Byte bytesSent = new Byte {0x00, 0x00, 0x00, 0xF6}; Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); // Send the message to be broadcast s.SendTo(bytesSent,...
7
7697
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 working because I can ping the multicast address and get responses from the server on the other network. I didn't think ping would work like that but...
1
4397
by: Nuno Magalhaes | last post by:
Does the function below returns an UDP packet, for example, from the local machine? Why does it give me an error: "The best overloaded method match for ReceiveFrom... has some invalid arguments". Why this error? How can I receive a packet from a specific adapter, for example, my local machine? Is there a better way? This way won't work. The...
0
1506
by: Nuno Magalhaes | last post by:
The MSDN says that I have to bind the socket on a local address to use ReceiveFrom function. How can I bind the socket on a multicast address in order to get the multicast data. Say that I want to receive data that is sent from 10.154.0.104:554 to 224.1.2.3:554. How can I get the data at 224.1.2.3:554 since this is a multicast address, and...
0
1157
by: zig158 | last post by:
My application will use a multicast channel for contacting peers on the network running the application, like mDNS. I have some sample code that works great on my local machine, but have a question how they will react on a multi router network. This code is currently 2 apps but will eventually be one multi thread app. This is the send...
1
2692
by: ssherm01 | last post by:
I'm using MS VS C++ .NET. I've written a multicast test utility that can send IGMP packets for a user specified group address. As well, it can send and receive UDP packets for a specified multicast group. I'm using the Sockets Class methods for sending and receiving packets. One area I'm having problems with is recieving IGMP packets on the...
1
4154
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")); udpClient.BeginReceive(new AsyncCallback(DoUDPReceive), this); My concern is that it seems to make exclusive use of port 4000 so I worry that in a Citrix...
2
1789
by: =?Utf-8?B?aXdkdTE1?= | last post by:
Hi, im writing a program that uses the multicast address to send data to multiple clients at the same time. I would like to be able to get the multicast address of the current network programmatically...is this possible, and if yes, how? ive done google searches, yet i havent found a thing on how to do this. thanks! -- -iwdu15
0
8103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7634
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7945
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5481
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.