473,397 Members | 2,056 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,397 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 1981
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
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
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.