newbie question connecting to windows service

B

Bob

Hi,
I would like to have a windows service that other client programs on
the same machine can communicate with. All the examples I have seen
use some variety of sockets or remoting to connect with the service.
I don't have much experience with remoting. Is there any way that I
can implement this that will not require allowing access (ie opening a
port) in the windows firewall?

Thanks,
Bob
 
S

Smithers

You can use the ServiceController to programmatically intereact with
services either on the local machine or on a remote machine:

http://msdn2.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx

and google "ServiceController" for more

And there is no point in referring to yourself as a "newbie" - true or not
it's totally irrellevant to anything and only hurts your chances of getting
a helpful reply. Look up "newbie" in this link and go from there...
 
M

Mr. Arnold

Bob said:
Hi,
I would like to have a windows service that other client programs on
the same machine can communicate with. All the examples I have seen
use some variety of sockets or remoting to connect with the service.
I don't have much experience with remoting. Is there any way that I
can implement this that will not require allowing access (ie opening a
port) in the windows firewall?

You might be able to use what's in the link instead of Remoting, but you're
going to have to use something like what you're talking about above, because
it's a one way communications between the Windows application to the
Service, otherwise.

You can also use temp files as well to communicate back to the Windows app
from the Service. But using files in your case may not be the router you may
want to take.

http://www.codeproject.com/cs/library/XDMessaging.asp
 
S

Smithers

RE:
<< ...but you're going to have to use something like what you're talking
about above, because it's a one way communications between the Windows
application to the Service, otherwise>>

That's not true at all. The ServiceController class lets you get information
from a service, in addition to sending commands to the service and waiting
for the service to report status back to your ServiceController. There's
nothing one way about it.

RE:
<< You can also use temp files as well to communicate back to the Windows
app from the Service >>

Why recommend some temp file hack when something so powerful and elegant as
the ServiceController exists? Seriously - is there some shortcoming of
ServiceController that can only be worked-around with a temp file hack?

-Smithers
 
M

Mr. Arnold

Smithers said:
RE:
<< ...but you're going to have to use something like what you're talking
about above, because it's a one way communications between the Windows
application to the Service, otherwise>>

That's not true at all. The ServiceController class lets you get
information from a service, in addition to sending commands to the service
and waiting for the service to report status back to your
ServiceController. There's nothing one way about it.

I know all about the ServiceController such as using OnCustomComands.

You're going to have to come up with some kind of proof here showing that
you can effectively do two way communications with just the
ServiceController and nothing else, if a serious desktop solution is going
to be done that's working with a .Net Service application and just using the
ServiceController, because I know better.

You're going to have to come up with an example -- show an example.
 
S

Smithers

For purposes of clarification, let's revisit the OP:
<< I would like to have a windows service that other client programs on the
same machine can communicate with.>>

ServiceController fits the bill. It communicates with a service - in two
directions even:.

ServiceController can SEND communications to a service via these methods:
..Start
..Stop
..Continue

and can receive information back FROM a service via these methods:
..GetDevices
..GetServices
..WaitForStatus

and via 11 properties of the ServiceController class, including:
.Status
..CanShutDown
etc

I suspect that where we are at apparent odds is over the OP's meaning of
"...communicate with."

That is a vague request on the part of the OP- so I gave him a good
reference for how we *can* "...communicate with" a service (in two
directions nonetheless).

RE:
<< because it's a one way communications >>

I suspect (and I'm sure you'll clarify if I'm wrong about this) that your
meaning of "... one way communications" relied on a more specific meanaing
of "communicate with" that involved sending and receiving custom application
or service-specific state data... in which case I would agree with you; with
the caveat that I'm not sure how we can even send custom state data TO a
service... in which case we wouldn't even have one-way communications (if
the definition of "communications" involves the transfer of custom state
data).

It just seemed to me that you were unfamiliar with, or at least not giving
credit to, the ways in which we can have two-way communications with a
service via ServiceController's built-in methods and properties. Thus my
intention to clarify for the benefit of the OP. Sorry if my style came
across as offensive.

-"Smithers"
 
M

Mr. Arnold

Smithers said:
For purposes of clarification, let's revisit the OP:
<< I would like to have a windows service that other client programs on
the same machine can communicate with.>>

You don't know what that means you don't know what the intent here is about,
If it was one Windows desktop client application that's one thing, but the
OP is talking multiple desktop solutions in communations with the NT Service
application, for whatever reasons.
ServiceController fits the bill. It communicates with a service - in two
directions even:.

ServiceController can SEND communications to a service via these methods:
.Start
.Stop
.Continue

I know this and that's limited communcations.
and can receive information back FROM a service via these methods:
.GetDevices
.GetServices
.WaitForStatus

That's limited.
and via 11 properties of the ServiceController class, including:
.Status
.CanShutDown
etc

Again, it's limited communications.

<snipped>

You'll have to assume that the OP saw all of what you're talking about and
is looking for mote than what the ServiceController can do in communicating
with Windows desktop client application.

You do know that some solutions can be built using a .NET Service as the
back-end solution to a database with the sending and receiving of data
to/from the Windows Desktop client application to/from the service, and you
do it with .Net Remoting with sending objects or data is sent in temp files
between the two applications.
 
B

Bob

You don't know what that means you don't know what the intent here is about,
If it was one Windows desktop client application that's one thing, but the
OP is talking multiple desktop solutions in communations with the NT Service
application, for whatever reasons.





I know this and that's limited communcations.




That's limited.




Again, it's limited communications.

<snipped>

You'll have to assume that the OP saw all of what you're talking about and
is looking for mote than what the ServiceController can do in communicating
with Windows desktop client application.

You do know that some solutions can be built using a .NET Service as the
back-end solution to a database with the sending and receiving of data
to/from the Windows Desktop client application to/from the service, and you
do it with .Net Remoting with sending objects or data is sent in temp files
between the two applications.

Thanks for all your advice! I should have been more specific that the
service is acting as a database and has to respond to a very large
number of commands with potentially a large amount of data.
Accordingly, I don't think servicecontroller or custom commands will
be enough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top