Question

I need a solution where an instance of an object containing configuration information is hosted in a windows service and many (up to 1000) or more simultaneous clients interact with this object.

Clients will access the object on startup and periodically during operation when the client performs its purpose. Clients will rarely update the config. Changes to the config must be communicated/reflected on all clients when they occur (no polling).

Is remoting a suitable solution for this? I hoped to avoid writing a full server & client system, dealing with sockets etc.

Was it helpful?

Solution

Yes, remoting is a suitable solution, however if you are using .NET 3.5 or above, you may consider using WCF which surpass remoting, and use nettcp binding.

OTHER TIPS

You may use SQL database for such use, like SQL Server or MySQL and add thin layer of server application (e.g. simple ASP.net application serving XML/JSON data) and scripts / application continuously querying the server.

WCF and SQL databases are both solutions worth considering but IMHO what you are describing is more closely related to remote procedure calling (RPC). RPC allows you to create a single object on a server which clients can interact with as if it were a local object (so completely avoid the need to deal with sockets). Alternatively each client can also create its own unique server object to interact with.

A full implementation of RPC can be found in the network library networkcomms.net. The following code snippet is taken from the RPC example.

Server side:

//Register a single object server side called "Calculator"
RemoteProcedureCalls.Server.RegisterInstanceForPublicRemoteCall<MathClass, IMath>(new MathClass(), "Calculator");

Client side:

//Get a reference to the remote object named "Calculator"
IMath calc = RemoteProcedureCalls.Client.CreateProxyToPublicNamedInstance<IMath>(connection, "Calculator", out instanceId);
//We can now use the calculator object as if it were local
//The following WriteLine outputs '12' where the calculation was performed on the server
Console.WriteLine(calc.Multiply(4, 3));

Disclaimer: I'm a developer for this library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top