views:

439

answers:

4

Is there something like twisted (python) or eventmachine (ruby) in .net land?

Do I even need this abstraction? I am listening to a single IO device that will be sending me events for three or four analog sensors attached to it. What are the risks of simply using a looped UdpClient? I can't miss any events, but will the ip stack handle the queuing of messages for me? Does all of this depend on how much work the thread tries to do once I receive a message?

What I'm looking for in an abstraction is to remove the complication of threading and synchronization from the problem.

A: 

Check out http://kayakhttp.com/

Darrel Miller
That's almost exactly what I need, only I don't need HTTP, I'm listening to UDP events. Thanks for the link though, sorry I was unclear.
Sam C
A: 

I would recommend ICE it's a communication engine that will abstract threading and communication to you (documentation is kind of exhaustive).

call me Steve
A: 

Problem is that with Udp you are automatically assuming the risk of lost packets. I've read the documentation on ICE (as Steve suggested), and it is very exhaustive. It appears that ICE will work for Udp, however, it appears that Tcp is preferred by the developers. I gather from the ICE documentation that it does not provide any intensive mechanisms to ensure reliable Udp communications.

It is actually very easy to set up an asynchronous Udp client or server. Your real work comes in checking for complete packets and buffering. The asynchronous implementations should keep you from managing threads.

dboarman
+3  A: 

I think you are making it too complicated. Just have 1 UDP socket open, and set an async callback on it. For every incoming packet put it in a queue, and set the callback again. Thats it.

make sure that when queuing and dequeueing you set a lock on the queue.

it's as simple as that and performance will be great.

R

Toad