kmarks2
kmarks2

Reputation: 4875

Interfacing with a localhost Windows service

I have a server I've written in C#. I need to interface with it so I can reconfigure things, purge caches, disconnect users, view a run console, etc. I can't shut the server down to do any of these things.

The two available options, interface with the server via a Tcp connection or use the Windows conventions (some WCF?).

Which is one more reliable or a "best practice":

Thanks in advance for the nearly always useful feedback.

EDIT: Can anyone offer any alternatives to WCF? The server itself is literally 65kb. It's tiny. And all I'm trying to do now is issue a few admin/maintenance commands to the server. I'm not trying to be the server, it's already done. I just want to interact with from a local host userland application.

EDIT 2: Problem solve: I'm just using a very very small Tcp client to issue requests to my already built out protocol. It's only a couple hundred lines and no bulky overkillish WCF had to be used. WCF just seems like...too too much. That said I need to learn it anyway (and am right now), thanks for the feedback!

Upvotes: 1

Views: 2413

Answers (2)

ken2k
ken2k

Reputation: 48985

I would definitely recommend using WCF. You define your endpoints and the contract, then using binding you configure how the communication is done (TCP, XML SOAP, Named pipes, message queues...).

This technology is pretty convenient: if you want to move for instance from TCP to HTTP SOAP, then you just update your configuration files and it's done; no code to update. Also it's totally interoperable as you can configure WCF to use HTTP (SOAP messages) and consume your services from any language/platform. You'll also find plenty of tutorials and examples on the web.

Here's a nice article about how to host WCF (TCP communication in the example, but you can use something else by modifying the configuration) within a Windows service

Upvotes: 2

mfeingold
mfeingold

Reputation: 7154

You can host a web service inside windows service. It would be TCP of course but without socket level programming on the client.

You can have then a restful interface on top of it. WCF always seemed too heavy to my liking

Upvotes: 0

Related Questions