471,603 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 software developers and data experts.

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 2474
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(udpPort);
IPEndPoint anyone = new IPEndPoint(IPAddress.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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Shawn G. | last post: by
2 posts views Thread by Robert Treat | last post: by
2 posts views Thread by Daniel Lindberg | last post: by
2 posts views Thread by OBones | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | last post: by

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.