Re: Architecture advise wanted.

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 08/03/04


Date: Tue, 3 Aug 2004 09:35:44 -0400


> Well, the problem is that the application must be doing many things
> (accepting UDP connections from UDP clients, accepting TCP/IP
> connections from other types of clients, pushing the data out to TCP
> clients, etc...) so I can't have stuff waiting around.

That I one reason I suggested the queue. Maybe I should expand (lets talk
udp for now).
1) Create a Listener Object and put Start() and Stop() methods on it. You
can listen to all IPs or selected IPs with multiple Listener Objects. Each
object will Contain its own tread.
2) Create your Server Object. This will read the network objects and
process them. Your main logic.
3) Add a *blocking* output queue. The Listener will output objects into
the queue. The Server Object will read objects from this queue.
4) Both the Listener will block/wait on full queue and Server will block on
empty queue. So no polling involved - very efficient.
5) The Server will make reply object and put into some output queue. Your
Listener could also be your Sender, or you can have another thread/object
for that job. You can share the Socket on different threads as long as one
reads and other writes. So you can have sender thread in your listener or
anothe object.
6) This shared queue works well as you can add Listener objects (say
listening on different IP addresses) sending objects to same output queue.
Your server object will just pick them out of the queue without knowing how
many Listeners are working. You can also "inject" objects into the queue
from out-of-band sources like Mgmt, etc. So it is flexible.

I have done just this in a upd/tcp server I am working on, so know it works
well.
Hope that makes some sense. Please post back if not. Cheers!
--wjs mvp



Relevant Pages

  • Re: Architecture advise wanted.
    ... >>connections from other types of clients, pushing the data out to TCP ... >That I one reason I suggested the queue. ... >1) Create a Listener Object and put Startand Stopmethods on it. ... The Server Object will read objects from this queue. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Deallocating records with task type fields.
    ... In fact the real environment record also has a protected output queue ... passing it to the Listener with a discriminant. ... Listener to arrange for its own deallocation. ...
    (comp.lang.ada)
  • Re: Deallocating records with task type fields.
    ... In fact the real environment record also has a protected output queue ... passing it to the Listener with a discriminant. ... Listener to arrange for its own deallocation. ...
    (comp.lang.ada)
  • Re: Architecture advise wanted.
    ... Your listener will put the packet ... Your Consumer will wait until the ... queue has an object and then go. ... Create a listener thread that listens for udp on port n. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using .Net Remoting for messaging, Help Needed
    ... the server puts its messages to them. ... i need to handle messages and transfer them to the relevant clients, ... i implemented a Listener for MSMQ, the problem is that it has a ... the messages in the Queue, not talking about what if message is ...
    (microsoft.public.dotnet.languages.csharp)