Sam Coles
Sam Coles

Reputation: 4043

Multi-threaded network UDP server library for .net

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.

Upvotes: 8

Views: 4287

Answers (4)

Durian
Durian

Reputation: 1

It sounds like you are looking for reliable multicast -You could try RMF , it will do the reliability and deliver the messages using asyc callbacks from the incoming message queue. IBM also does WebSphere which has a UDP component. EmCaster is also an option - however development seems to have stopped back in 2008.

If you aren't going to be transmitting these packets (or events) to other machines you might just want to use something simple like memory mapped files or other forms of IPC.

Upvotes: 0

Toad
Toad

Reputation: 15935

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

Upvotes: 6

IAbstract
IAbstract

Reputation: 19881

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.

Upvotes: 0

call me Steve
call me Steve

Reputation: 1727

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

Upvotes: 0

Related Questions