473,564 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JoinMulticastin gGroup & Compact Framework

Ben
Hello,

I'm having trouble with the JoinMulticastin gGroup 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 UDPMulticastLis tener
{
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(Grou pAddress, GroupPort);

try
{
listener.JoinMu lticastGroup(Gr oupAddress, 50);
listener.Connec t(groupEP);

while (!done)
{
Console.WriteLi ne("Waiting for broadcast");
byte[] bytes = listener.Receiv e(ref groupEP);

Console.WriteLi ne("Received broadcast from {0} :\n {1}\n",
groupEP.ToStrin g(),
Encoding.ASCII. GetString(bytes , 0, bytes.Length));
}

listener.Close( );

}
catch (SocketExceptio n e)
{
Console.WriteLi ne(e.toString() );
Console.ReadLin e();
}
}

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

return 0;
}
}

I'm having this message : System.Net.Sock ets.SocketExcep tion: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 1997
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 JoinMulticastin gGroup 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 UDPMulticastLis tener
{
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(Grou pAddress, GroupPort);

try
{
listener.JoinMu lticastGroup(Gr oupAddress, 50);
listener.Connec t(groupEP);

while (!done)
{
Console.WriteLi ne("Waiting for broadcast");
byte[] bytes = listener.Receiv e(ref groupEP);

Console.WriteLi ne("Received broadcast from {0} :\n {1}\n",
groupEP.ToStrin g(),
Encoding.ASCII. GetString(bytes , 0, bytes.Length));
}

listener.Close( );

}
catch (SocketExceptio n e)
{
Console.WriteLi ne(e.toString() );
Console.ReadLin e();
}
}

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

return 0;
}
}

I'm having this message : System.Net.Sock ets.SocketExcep tion: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
2501
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 Visual Studio 2003 ships with the functionality for .Net Compact Framework development. But right now I have Visual Studio 2002. Is there anything I...
14
1798
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
1233
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 another problems? Thank you carmen
1
252
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 network, by UDP protocol. Here is a sample of my code : public class UDPMulticastListener { private static readonly IPAddress GroupAddress =
5
3774
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 Framework 2.0 - I cannot find any compatibility between this as there only seems to be support for CF2 on PocketPC/2003 and CE.NET 5 I have also...
0
1447
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 (their code example in c# compile but didnt function propertly..) Thanks,
0
1586
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 Compact Server 2005 to process the data on the desktop with a final export to Access format. I have Crystal Reports XI and my VB.Net 2005 is also...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7642
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
7950
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...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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
5213
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
3643
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
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.