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

JoinMulticastingGroup & Compact Framework

Ben
Hello,

I'm having trouble with the JoinMulticastingGroup function with C#
..NET and the Compact Framework. My console application on my PocketPC
has to listen for any datagrams coming from the network, by UDP
protocol. Here is a sample of my code :

public class UDPMulticastListener
{
private static readonly IPAddress GroupAddress =
IPAddress.Parse("127.0.0.1");
private const int GroupPort = 9000;

private static void StartListener()
{
bool done = false;

UdpClient listener = new UdpClient();
IPEndPoint groupEP = new IPEndPoint(GroupAddress, GroupPort);

try
{
listener.JoinMulticastGroup(GroupAddress, 50);
listener.Connect(groupEP);

while (!done)
{
Console.WriteLine("Waiting for broadcast");
byte[] bytes = listener.Receive(ref groupEP);

Console.WriteLine("Received broadcast from {0} :\n {1}\n",
groupEP.ToString(),
Encoding.ASCII.GetString(bytes, 0, bytes.Length));
}

listener.Close();

}
catch (SocketException e)
{
Console.WriteLine(e.toString());
Console.ReadLine();
}
}

public static int Main(String[] args)
{
StartListener();

return 0;
}
}

I'm having this message : System.Net.Sockets.SocketException:An
invalid argument was supplied

I've put the address "127.0.0.1" because I want the application to
catch any datagram comming from the network, so it has to work
localhost. For what I've read from the msdn, the range has to be
between 224.0.0.0 and 239.255.255.255. But if I specify and address in
this range, I have the same message.

Instead of posting "e.toString()", if I post "e.ErrorCode()", I
receive the error code 10022, but I have absolutely no idea what it
means, and I didn't find any much help on that matter on the msdn.

Thanks in advance for the help you could give me...
Jul 21 '05 #1
1 1980
I think you may need to remove Connect command. See
http://groups.google.co.uk/groups?hl...3DN%26tab%3Dwg
for a useful discussion on IP multicasting.

Couple of other minor points. I would suggest creating the UdpCLient object
in a using block, as if your code encounters an exception, the UdpClient
object will not be disposed. Also, cannot see where done is set to true to
allow loop to break.

Of course, this could just be demo code, in whichc ase ignore me!

HTH
Dan

"Ben" wrote:
Hello,

I'm having trouble with the JoinMulticastingGroup function with C#
..NET and the Compact Framework. My console application on my PocketPC
has to listen for any datagrams coming from the network, by UDP
protocol. Here is a sample of my code :

public class UDPMulticastListener
{
private static readonly IPAddress GroupAddress =
IPAddress.Parse("127.0.0.1");
private const int GroupPort = 9000;

private static void StartListener()
{
bool done = false;

UdpClient listener = new UdpClient();
IPEndPoint groupEP = new IPEndPoint(GroupAddress, GroupPort);

try
{
listener.JoinMulticastGroup(GroupAddress, 50);
listener.Connect(groupEP);

while (!done)
{
Console.WriteLine("Waiting for broadcast");
byte[] bytes = listener.Receive(ref groupEP);

Console.WriteLine("Received broadcast from {0} :\n {1}\n",
groupEP.ToString(),
Encoding.ASCII.GetString(bytes, 0, bytes.Length));
}

listener.Close();

}
catch (SocketException e)
{
Console.WriteLine(e.toString());
Console.ReadLine();
}
}

public static int Main(String[] args)
{
StartListener();

return 0;
}
}

I'm having this message : System.Net.Sockets.SocketException:An
invalid argument was supplied

I've put the address "127.0.0.1" because I want the application to
catch any datagram comming from the network, so it has to work
localhost. For what I've read from the msdn, the range has to be
between 224.0.0.0 and 239.255.255.255. But if I specify and address in
this range, I have the same message.

Instead of posting "e.toString()", if I post "e.ErrorCode()", I
receive the error code 10022, but I have absolutely no idea what it
means, and I didn't find any much help on that matter on the msdn.

Thanks in advance for the help you could give me...

Jul 21 '05 #2

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

Similar topics

1
by: Asad Khan | last post by:
Hi, I have Visual Studio 2002 Enterprise Architecture Edition. I was wondering if anyone has any information on how I can develop applications for .Net Compact Framework using this IDE. I've heard...
14
by: Ioannis Vranos | last post by:
Is there any way to develop .net compact framework applications from within VS 2003? There isn't such an option in the new project options.
0
by: carmen | last post by:
I was try an example about "manipulating graphical objects" in a windows CE system and I get an error because "Matrix" cann't be found in the compact framework. Is it true or perhaps there are...
1
by: Ben | last post by:
Hello, I'm having trouble with the JoinMulticastingGroup function with C# ..NET and the Compact Framework. My console application on my PocketPC has to listen for any datagrams coming from the...
5
by: Martin Robins | last post by:
Can somebody please confirm my suspicion; I have been presented with a Windows CE.NET 4.2 device (not PocketPC) and have been asked to develop an application using Vusiau Studio 2005 and Compact...
0
by: shaiamiel | last post by:
Hello, Im looking for a VOIP SDK that will be appliciable to both PC & Pocket PCs using the .net framework & c#. Does anyone know such thing? I tried bear soft's SDK but it didnt work so well...
0
by: The Mad Ape | last post by:
Hi experts. I am using VB.Net 2005 as my development environment. I have created an application for the Pocket PC. The data is transferred to the desktop via OpenNETCF and then I use SQL...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
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
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...

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.