473,729 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UDPClient Broadcast Receive Error with PPPOE

My Computer is Win2K3 R2, Code is:

using System;
using System.Net;
using System.Net.Sock ets;
using System.Threadin g;

namespace TechUDPBroadcas t {
class Program {
static void Main(string[] args) {
const string addr = "224.1.3.99 ";
const int prt = 12799;

UdpClient udpc = new UdpClient();
udpc.Client.Set SocketOption(So cketOptionLevel .Socket,
SocketOptionNam e.ReuseAddress,
true);
udpc.Client.Bin d(new IPEndPoint(IPAd dress.Any, prt));
udpc.EnableBroa dcast = true;

udpc.JoinMultic astGroup(IPAddr ess.Parse(addr) );

ManualResetEven t abort = new ManualResetEven t(false);
WaitHandle[] evs = new WaitHandle[2];
evs[0] = abort;
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(de legate {
while (true) {
IAsyncResult asy = udpc.BeginRecei ve(
new AsyncCallback(d elegate(IAsyncR esult
iasy) {
IPEndPoint rp = null;
byte[] recv = udpc.EndReceive (iasy, ref rp);
Console.Write(" .");
}), null);
evs[1] = asy.AsyncWaitHa ndle;
if (WaitHandle.Wai tAny(evs) == 0) return;
}
}));
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(de legate {
for (int i = 0; i < 1000; i++) {
udpc.Send(new byte[] { 0x1, 0x2 }, 2,
new IPEndPoint(IPAd dress.Parse(add r),
prt));
Console.Write(" +");
Thread.Sleep(10 00);
if (abort.WaitOne( 0, false)) return;
}
}));
Console.ReadKey ();
Abort.Set();
}
}
}
When my computer is single network connection(Loca l Network),
the code works fine. My problem is, when i connect the Internet with PPPOE,
the UDPClient can not receive the broadcasting data!

Why?

greenxiar
Mar 24 '07 #1
3 2307
On Sat, 24 Mar 2007 05:50:01 -0700, greenxiar <gr*******@hotm ail.com>
wrote:
[...]
When my computer is single network connection(Loca l Network),
the code works fine. My problem is, when i connect the Internet with
PPPOE, the UDPClient can not receive the broadcasting data!
Broadcast datagrams are not routable over the Internet (and for good
reason, if you think about it).

You'll need to use multicast or send the datagram directly to a given IP
address if you expect the client to receive any data over the Internet.
Mar 24 '07 #2
When the app is running at local network(Interne t not connected),
the sending and receiving are good.
Then i launch the internet connection, the app stop receiving immediately.
The data packages are sent to both Local and Internet
(In Netmon.exe i can see it). Why UdpClient stop receiving?
What happened when i connect the internet?

"Peter Duniho" <Np*********@nn owslpianmk.comÐ ´ÈëÏûÏ¢
news:op******** *******@petes-computer.local. ..
On Sat, 24 Mar 2007 05:50:01 -0700, greenxiar <gr*******@hotm ail.com>
wrote:
>[...]
When my computer is single network connection(Loca l Network),
the code works fine. My problem is, when i connect the Internet with
PPPOE, the UDPClient can not receive the broadcasting data!

Broadcast datagrams are not routable over the Internet (and for good
reason, if you think about it).

You'll need to use multicast or send the datagram directly to a given IP
address if you expect the client to receive any data over the Internet.

Mar 24 '07 #3
On Sat, 24 Mar 2007 12:36:16 -0700, greenxiar <gr*******@hotm ail.com>
wrote:
When the app is running at local network(Interne t not connected),
the sending and receiving are good.
Then i launch the internet connection, the app stop receiving
immediately.
The data packages are sent to both Local and Internet
(In Netmon.exe i can see it). Why UdpClient stop receiving?
What happened when i connect the internet?
Sorry...I misunderstood and thought you were trying to send over the PPPOE
connection.

Just to make sure I have things straight: you have a UDP client receiving
UDP broadcast datagrams; it works fine when you are not connected to the
Internet, but when you make a connection to the Internet using PPPOE, it
stops receiving the broadcast datagrams.

If so, I suspect it is still related to the fact that datagrams can't be
routed over the Internet. It sounds as though the network adapter on the
computer, once PPPOE is connected, treats all communications as though
they are over the Internet. Why this should be exactly I can't say for
sure, not being that familiar with PPPOE. Maybe someone else has a better
answer.

You may get some insight by using ipconfig to display the network
configuration for your network adapter, to see what happens to the local
IP address and routing/gateway information. That may help you see what
changes that causes the broadcasts to be blocked. Whether that would lead
to a solution, I don't know...if you are running into a fundamental change
in the network configuration that blocks the datagrams, you may be stuck
with the same limitations that exist over the Internet proper.

Pete
Mar 24 '07 #4

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

Similar topics

4
16041
by: Morten Overgaard | last post by:
Hi I'm listening on the SysLog port (514) through UDP. The problem is that I am not receiving anything nut I know that i get messages on the port. When I use KIWI to listen on the same port via UDP tons of messages arrive.. What am I'm doing wrong My code looks like the following... private UdpClient udpClient;
2
9521
by: goodmannewz | last post by:
I just cannot run the sample code from msdn. Please tell me why? Thanks a lot. I create a console C# project, parsed the example codes: public class UDPMulticastListener { private static readonly IPAddress GroupAddress = IPAddress.Parse("192.168.0.1"); private const int GroupPort = 9200; private static void StartListener()
1
7845
by: Steve | last post by:
Please take a look at the simple code segment below and advise me what is wrong. According to the help and examples I've seen it should work unless I misunderstand something. The problem is that UdpClient.Receive method always throws following exception, even though I verified that message was successfuly received by devices and responses were sent back:
3
13690
by: D. André Dhondt | last post by:
In VB.NET 2003, is there a way to create a System.Net.Sockets.UDPClient to listen to any address AND any port? I can get it to listen to any address, but only if I specify a port (for example, port 12345): '----------- Dim udpClient as New Sockets.UdpClient(12345) Dim ipEndPoint as New IPEndPoint(IPAddress.Any, 0) Dim receiveBytes as Byte()
1
3413
by: gregory_may | last post by:
I want to bind multiple UDPClients to the same port on the same machine. I want them to all listen for broadcast messages & respond accordingly. Multiple client bindings "under normal circumstances" doesn't work (That's the error I am getting). But, it seems very reasonable to set up many UDPclients to receive the same broadcast messages off the same port on the same machine. Is there some way to passively bind multiple UDPclients...
0
2208
by: tccode97 | last post by:
To whom it may concern, I am developing a socket application in VC++ that uses asynchronous connnection. After doing search on google, I found the following link http://msdn2.microsoft.com/en-us/library/system.net.sockets.udpclient.beginreceive.aspx First of all, thanks for microsoft team for this post.
1
3584
by: greenxiar | last post by:
My code is below and the platform is Win2K3 R2: using System; using System.Net; using System.Net.Sockets; using System.Threading; namespace TechUDPBroadcast { class Program { static void Main(string args) {
7
3573
by: | last post by:
I have the following program using System; using System.Collections; using System.Net.Sockets; using System.Net; using System.IO; public class Test { public static void Main(string s) {
0
1650
by: Johan | last post by:
Suppose: There are two devices on my network that both broadcast UDP datagrams (and they both use the same portnumber 1234). I want to create two executables that use UdpClient internally. Each executable should only receive the datagrams from one device. Is this possible? Lets say the devices are 10.0.0.1 and 10.0.0.2. I have already tried something like this: UdpClient udpClient = new UdpClient(1234);
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9142
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.