473,406 Members | 2,208 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,406 software developers and data experts.

UDPClient Broadcast Receive Error with PPPOE

My Computer is Win2K3 R2, Code is:

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;

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

UdpClient udpc = new UdpClient();
udpc.Client.SetSocketOption(SocketOptionLevel.Sock et,
SocketOptionName.ReuseAddress,
true);
udpc.Client.Bind(new IPEndPoint(IPAddress.Any, prt));
udpc.EnableBroadcast = true;

udpc.JoinMulticastGroup(IPAddress.Parse(addr));

ManualResetEvent abort = new ManualResetEvent(false);
WaitHandle[] evs = new WaitHandle[2];
evs[0] = abort;
ThreadPool.QueueUserWorkItem(new WaitCallback(delegate {
while (true) {
IAsyncResult asy = udpc.BeginReceive(
new AsyncCallback(delegate(IAsyncResult
iasy) {
IPEndPoint rp = null;
byte[] recv = udpc.EndReceive(iasy, ref rp);
Console.Write(".");
}), null);
evs[1] = asy.AsyncWaitHandle;
if (WaitHandle.WaitAny(evs) == 0) return;
}
}));
ThreadPool.QueueUserWorkItem(new WaitCallback(delegate {
for (int i = 0; i < 1000; i++) {
udpc.Send(new byte[] { 0x1, 0x2 }, 2,
new IPEndPoint(IPAddress.Parse(addr),
prt));
Console.Write("+");
Thread.Sleep(1000);
if (abort.WaitOne(0, false)) return;
}
}));
Console.ReadKey();
Abort.Set();
}
}
}
When my computer is single network connection(Local 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 2277
On Sat, 24 Mar 2007 05:50:01 -0700, greenxiar <gr*******@hotmail.com>
wrote:
[...]
When my computer is single network connection(Local 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(Internet 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*********@nnowslpianmk.comдÈëÏûÏ¢
news:op***************@petes-computer.local...
On Sat, 24 Mar 2007 05:50:01 -0700, greenxiar <gr*******@hotmail.com>
wrote:
>[...]
When my computer is single network connection(Local 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*******@hotmail.com>
wrote:
When the app is running at local network(Internet 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
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...
2
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...
1
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...
3
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,...
1
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...
0
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 ...
1
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...
7
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
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...
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?
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
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,...
0
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...
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
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...
0
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,...
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.