473,508 Members | 2,233 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any good example of Non-blocking UDP read?

I have been searching and can not seem to find a good example of a
working UDP client that listens, but does not block while waiting for
data arrival.

I am trying to write a client application that needs to listen on
several TCP ports and one UDP port. It will send a start signal over
UDP and then a repeated status message of a fixed length will be
returned from the server. I need to listen to these messages, but I
can't stop the program execution if no message is available yet like
the UdpClient.Receive method does. I have found several example of
async TCP but can not figure out how this would work with UDP.

Does anyone have a working example of a non-blocking UDP client, or
can someone give me some guidance in this area?

Thanks!
Nov 15 '05 #1
2 13364
Tash,

While this isn't an example, this can be done fairly easily with
Socket.BeginReceiveFrom(). Pass this function a delegate, and that delegate
will be called right away from a separate thread. In this delegate you
should then call EndReceiveFrom(), which will block until data is read --
but remember, this blocking happens on a separate thread, so your main
thread can continue to run.
"Tash Robinson" <ta***@kc-automation.com> wrote in message
news:2d**************************@posting.google.c om...
I have been searching and can not seem to find a good example of a
working UDP client that listens, but does not block while waiting for
data arrival.

I am trying to write a client application that needs to listen on
several TCP ports and one UDP port. It will send a start signal over
UDP and then a repeated status message of a fixed length will be
returned from the server. I need to listen to these messages, but I
can't stop the program execution if no message is available yet like
the UdpClient.Receive method does. I have found several example of
async TCP but can not figure out how this would work with UDP.

Does anyone have a working example of a non-blocking UDP client, or
can someone give me some guidance in this area?

Thanks!

Nov 15 '05 #2
"Tash Robinson" <ta***@kc-automation.com> wrote in message
news:2d**************************@posting.google.c om...
I have been searching and can not seem to find a good example of a
working UDP client that listens, but does not block while waiting for
data arrival.

I am trying to write a client application that needs to listen on
several TCP ports and one UDP port. It will send a start signal over
UDP and then a repeated status message of a fixed length will be
returned from the server. I need to listen to these messages, but I
can't stop the program execution if no message is available yet like
the UdpClient.Receive method does. I have found several example of
async TCP but can not figure out how this would work with UDP.

Does anyone have a working example of a non-blocking UDP client, or
can someone give me some guidance in this area?


Put the socket in non-blocking mode and use Select() to check for
any number of readable file descriptors. That's the standard way
of doing this. (Currently, Select() can't be used to block indefinitely --
see the concurrent thread with subject "Blocking Select() does not work."

Cheers,

Michi.

--
Michi Henning Ph: +61 4 1118-2700
ZeroC, Inc. http://www.zeroc.com
Nov 15 '05 #3

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

Similar topics

226
12318
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
77
3974
by: Hunn E. Balsiche | last post by:
in term of its OO features, syntax consistencies, ease of use, and their development progress. I have not use python but heard about it quite often; and ruby, is it mature enough to be use for...
2
3000
by: CoolPint | last post by:
Can anyone kindly explain why non-type template parameters are required by giving some examples where their uses are clearly favourable to other alternatives? I cannot think of any good use for...
5
1928
by: sandwich_eater | last post by:
I am looking for a Linux distribution and a standard C++ compiler (IDE not too important) that can also compile to Win32, to run on my Dell dimension 2400... I have trouble with new distros since...
24
2260
by: Gaijinco | last post by:
I found one of that problems all of us have solve when they begin programming: given 3 numbers print the greater and the lesser one of the set. I was trying to remember the if-then-else...
3
1541
by: Strasser | last post by:
In a nested subform in datasheet view, an interviewer of homeless people picks a descriptive CATEGORY from 20 descriptive categories. The 20 categories are displayed via a combo box. (Categories...
206
8170
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
76
3964
by: lorlarz | last post by:
Crockford's JavaScript, The Good Parts (a book review). This shall perhaps be the world's shortest book review (for one of the world's shortests books). I like Douglas Crockford (because I am a...
23
1240
by: tkpmep | last post by:
I have a list that starts with zeros, has sporadic data, and then has good data. I define the point at which the data turns good to be the first index with a non-zero entry that is followed by at...
22
1535
by: raylopez99 | last post by:
Here is a classic example of why C# is like beating your head against the wall. I can tell you where the error is in the below code--it's the "NumberStyles" property of DecimalParse (which...
0
7225
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
7326
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,...
0
5627
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
4707
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...
0
3194
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
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 ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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...

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.