What you've described sounds eminently doable. Though I'm going to question a couple of things and I'd probably make a few adjustments.
- Why does the client need to reconnect every 3 or 4 seconds?
Constantly re-making connections is a costly affair. That why http (web) servers went over to persistent connections.
Why not let the client continue to listen and just send it data as it arrives from the remote system?
Or perhaps better would be for the client to open a local UDP port and once it has communicated the hostname/command pair/and port number to the service it just sits back and monitors the UDP port to retrieve the output.
- Why accumulate the data in a queue, rather than just a (non-shared) array or even a scalar?
I guess this is because you envisage the client re-connecting to the servers primary thread to retrieve the output and so you need accumulate the data in a shared structure so the primary thread can get access to it.
It think this is a bad design. You are making it so that your primary thread has to be involved in all data retrieval by every client; thus setting yourself up with a bottleneck. It also complicates the processing, by requiring shared data structures and uses more memory because shared data is duplicated.
I think -- without being fully aware of your requirements -- that a better design would be to have the primary (listening) thread start dedicated thread(s) (one or two depending upon the answer to the above) for each client/command and accumulate the buffered output entirely local to that (those) threads.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|