473,378 Members | 1,110 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,378 software developers and data experts.

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 to
How can I get the data at 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)?



Here's a simple code that blocks:

public MulticastServer(int localPort)
Socket(AddressFamily.InterNetwork,SocketType.Dgram ,ProtocolType.Udp);
IPHostEntry IPHost=Dns.GetHostByName(Dns.GetHostName());
IPAddress ip=IPAddress.Parse(IPHost.AddressList[0].ToString());
IPEndPoint ep=new IPEndPoint(ip,localPort);

public byte[] ReceiveFrom(string ipAddress,int port)
//if(socket.Available==0)return null;
IPEndPoint ep=new IPEndPoint(IPAddress.Any,0);
EndPoint ep2=(EndPoint)ep;
byte[] buffer=new byte[1500];
int receivedBytes=socket.ReceiveFrom(buffer,ref ep2);
byte[] packet=new byte[receivedBytes];
return packet;

Jan 17 '06 #1
0 1593

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

Similar topics

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...
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 =...
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...
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"....
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...
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...
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...
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(""));...
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...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
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,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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$) { } ...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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.