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... 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... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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.
|
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
|
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 =
|
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...
| |
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,
|
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...
|
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. ...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |