473,698 Members | 2,302 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 2306
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
16039
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
9518
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
7843
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
13687
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
3405
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
2206
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
3578
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
3570
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
1645
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
8674
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
8604
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
9157
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9028
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7728
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...
0
4369
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2330
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.