I would like to write a service (for Win2k) in Vb.net that would provide access to instrumentation to multiple client apps (not necessarily over a network). Do services have this capability? From what I've learned so far, it appears possible, however, I'm not yet clear on how the interface between the client and service works. Does the client have to go through the Service Controller or can it talk directly to the service? How does the service initiate communication to all its clients?
In .NET, this is done through remoting. Remoting is the mechanism that you use for inter-process communication regardless of whether it is across a network or on the same machine. The following link will take you to the remoting conceptual topic in MSDN for VS.NET 2002.
As David mentioned, in .NET the objects would be exposed to clients through remoting. The hosting application, though, could be a Windows service. Once the service is started and has registered the types that will be exposed through the remoting infrastructure, clients can get references to the remoted objects directly from the service and do not have to use ServiceController. ServiceController is used more for applications that are going to start/stop, administrate, configure, etc. the service.
Thanks for that. Is there any benefit in creating the server as a service? It seems that the client apps would have an easier time in locating the server if it were a registered service. Is this correct? My impression now is that services are just server objects that can be found/accessed using the ServiceController.
It won't make any difference to the client whether the server is a service or not. The client does not need to know whether the server is a Windows service because from its perspective it's getting a reference to a well-known object via a URL. The client does not and should not need to use ServiceController to access the remoted objects that the service is exposing.
Off the top of my head, here are a few advantages to making the server a service:
You can make the server run in the background and not appear in Task Manager or in the Windows task bar.
You can configure it (via its associated ServiceInstaller or the Service Control Manager) to automatically start when the system starts.
A service c an be configured to run under an account under than the account of the logged-on user.
A service can run without a user being logged onto the computer.