I'm just learning c#, and am programming a Home windows client that collects temperature data in the computer and requires to transmit it to some remote linux mySQL Database.
I would program it directly within the c# client, but I wish to find out more ways to get this done and gain experience. And programming it directly could be less secure and many likely require an additional connector.
Can any one of you advise me of different ways, or ways you'd do that?
In whatever way to program a C# program that functions like a web-service on my small linux mySQL Server? Where must i look/search to explore this. Could it be known as something? Or possibly it is not completed in C#?
Must I program a php script that accepts HTTP SEND/GET demands from the C# Desktop client?
Every other way?
What strategy is most 'professional' within the real life? Learning by myself! :D
- Home windows Desktop: client designed in C# That retrieves temp data and requires to transmit to server
- Linux Server: Runs Apache and mySQL Server having a database already setup. Closed to outdoors Connections
Make an effort to to setup an internet service to talk with your home windows client. Directly hooking up to mysql server is alright when they both resident inside a same lan, but when not, for instance your home windows client is running on some laptop travelling everywhere or perhaps the mysql server permits local incoming connection only, your should setup an internet service. Even the http connection usually can undergo fire walls while connections over other ports are blocked.
php is a great way to do that. As you are learning c#, you might want to use c# to complete the server side programming too, so why wouldn't you provide a try of mono?
When the temperature sensor creates occasions, i quickly would 'push' the information in the Home windows box towards the Linux box - this can save the second checking frequently and finding no updates. However if you're just taking temperature samples, I'd 'pull' the information in the Linux machine. In either case, if you wish to use HTTP you may need a web service on each side.
Alternatively, you can just connect with your MySQL database remotely from C#, and write the information directly (no web service would then be needed). That could be the fastest method of getting this working.
The 'which is professional' real question is subjective - the 3 options above are fine. Simply make the code obvious and concise :)
Directly subjecting a MySQL Server to the web is strongly dicouraged, Furthermore this provides a rather coarse-grained group of access privileges, that is probably not enough for the application, so running some kind of server application is the proper way to go.
- With mono you are able to run lots of .Internet (and therefore C#) based code on the Linux server all right. Guideline is: Whether it does not possess a Winforms GUI with no P/Invoke it'll work all right. Ofcourse this needs mono around the server, which isn't given of all commercial hosts.
- Running the server in PHP causes it to be much more portable, but includes a performance overhead. Furthermore it does not permit a number of your busines logic objects to become implemented inside a DLL set up and utilized on each side.
- For the protocol: Chose your poison. Guideline again is, that predefined methods for example Cleaning soap often need a little more work (and much more learning within the very first time), but around the long-term tend to be robust.
For the special use-situation I would opt for a fast PHP based solution in which the protocol is simply a simple GET having a couple of parameters, one being the temperature(s) and also the others authenticating the customer.