Re: Architecture advise wanted.
From: Frank Rizzo (none_at_none.com)
Date: 08/03/04
- Next message: msnews.microsoft.com: "ISAPI in C++.net Book Recommendation Needed"
- Previous message: Alan Zhong: "visual studio resource file?"
- In reply to: William Stacey [MVP]: "Re: Architecture advise wanted."
- Next in thread: William Stacey [MVP]: "Re: Architecture advise wanted."
- Reply: William Stacey [MVP]: "Re: Architecture advise wanted."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 03 Aug 2004 10:07:28 -0700
William Stacey [MVP] wrote:
>>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
>
>
The design makes sense, but I am not understanding how the listener will
let the Server object know that a new message has arrived.
I am assuming that in the Listener you do the following after you have
received the message.
SyncLock
cQueue.Add NewMessage
End SyncLock
But how does the Server object know that something has been added to the
queue?
Thanks
But
- Next message: msnews.microsoft.com: "ISAPI in C++.net Book Recommendation Needed"
- Previous message: Alan Zhong: "visual studio resource file?"
- In reply to: William Stacey [MVP]: "Re: Architecture advise wanted."
- Next in thread: William Stacey [MVP]: "Re: Architecture advise wanted."
- Reply: William Stacey [MVP]: "Re: Architecture advise wanted."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|