473,805 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Receive UDP Broadcast

Does anyone have an example of how to receive a connectionless( udp)
broadcast in c#. I have tried everything i can possibly think of and
it won't recieve the message. I know that the message is coming in and
that its not being blocked because there is another app on my machine
that is getting the message. Please help.

Dec 20 '05 #1
2 2593
Hello Dave,

See there http://samples.gotdotnet.com/quickst...hatClient.aspx

D> Does anyone have an example of how to receive a connectionless( udp)
D> broadcast in c#. I have tried everything i can possibly think of and
D> it won't recieve the message. I know that the message is coming in
D> and that its not being blocked because there is another app on my
D> machine that is getting the message. Please help.
D>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Dec 20 '05 #2
I can show you how I do it, but I've never been properly trained in
network coding, so this might not be the best way.

ing udpPort = 8085;

UdpClient clientListener = new UdpClient(udpPo rt);
IPEndPoint anyone = new IPEndPoint(IPAd dress.Any, 0);

byte[] data = clientListener. Receive(ref anyone);

Note that this method will block on the .Receive until something is
received, so you might want to do this in a seperate thread and then
pass the byte array back to your main thread. Also, I've found that I
don't really like Udp much and have switched mostly to Tcp type
programming, but Udp does have its advantages. I hope this helps, let
me know if you want to see some more code.

Dec 21 '05 #3

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

Similar topics

1
7850
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:
2
2416
by: Shawn G. | last post by:
I'm going around in circles here and need some help. Scenario: I am using (have used) either the UDPClient class or Sockets class to broadcast some bytes to 255.255.255.255 (udp protocol). Upon doing so, a device (of which I will know nothing about) will receive my broadcast and send out a broadcast of its own. Using Ethereal (LAN packet sniffer), I can see my broadcast, and I can see the device broadcast. I cannot however receive...
2
1976
by: Robert Treat | last post by:
We got a few of these on a 7.3 server this afternoon. The server was completed pegged on i/o activity (both physical disks, including the one the db doesn't live on) May 12 15:15:51 gnvdb01 postgres: LOG: PGSTATBUFF: Warning - receive buffer full May 12 15:15:52 gnvdb01 postgres: LOG: PGSTATBUFF: Warning - receive buffer full May 12 15:15:52 gnvdb01 postgres: LOG: PGSTATBUFF: Warning - receive buffer full
2
5789
by: Daniel Lindberg | last post by:
Hi, im a beginner in C# and i just cant seem to get my udp broadcasting to work. What happens is that it just locks down on the Receive call and never gets any data. I have the code for the server who answers the broadcast, so i know that it sends a reply, but i cant figure out why my C# client cant receive it.. Any input on whats wrong with my code will be appreciated //My code...
3
2310
by: greenxiar | last post by:
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) {
3
3419
by: siujoe | last post by:
Hi, My app is written in vb.net 2003, I need to receive broadcast messages sent from another application written in VC++6. It doesn't seem i can import system.messaging, I also tried windows API RegisterWindowMessage but no luck.
0
1654
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);
2
6551
by: OBones | last post by:
Hi all, I'm currently trying to receive replies to a UDP broadcast that I sent and I can't get it to work. I know the datagrams are sent as I see them with WireShark, but my C# code does not see them. Here is how I intended things to work: Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); try
0
1845
by: cweckel2000 | last post by:
Hi all, I'm new to developing applications using networking protocols and need to figure out how to send/receive data between a server and 8 different devices. I don't have much code as I am still in the planning stages, but I'm confused about the best way to send / receive data. On program startup I plan on sending a broadcast ping and then listening for the 8 device's responses. What is the best way to receive the data? I've done some...
0
9716
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
9596
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,...
1
10366
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9185
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
6876
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
5542
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
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4323
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
3
3007
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.