My thought is to have the service start a new thread that handles socket connections and responses while the main thread runs the looping processes. Would it be hard for it to view some main thread variables to obtain status?

No, no problem at all. Just share the variables that you want the status thread to be able to see, and add:

my $sharedVar : shared; .... { lock( $sharedVar ); #do stuff with $sharedVar }

around each access to those shared variables in both pieces of code.

If your going to use a package like IO::Socket::INET to provide the communications within the status thread, require it within that thread rather than useing it at the top of the script.

In essence that is all there is to it.

There are some limitations about what types of variable can be shared--filehandles (hackable) and objects or tied vars (not easily hackable)--but that needn't be a great limitation.

Does anyone have any thoughts on a direction for this task?

From your description so far, using a thread would seem the ideal route to me.

Of course, the devil is in the detail--in this case, the detail of exactly what information you want to share between the threads.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

In reply to Re: Thoughts on how to devise a queryable win32 service by BrowserUk
in thread Thoughts on how to devise a queryable win32 service by noslenj123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.