Go Premium for a chance to win a PS4. Enter to Win


C# - Questions about developing a client/server application

Posted on 2014-01-10
Medium Priority
Last Modified: 2014-02-08
I have developed a barcoding application in c# as a means of learning c# and .NET. Whilst the application utilises a SQL database on a remote server - it is not a client server application and as such requires a lot of needless setup on each individual PC which would not be required if it had been developed as a client/server system. I am now looking at re-developing this as a client/server application. All of the background processing will be done on the server and the screen inputs will be processed by the client. That being said - I know little or nothing about client server. I have some basic questions, such as:

- Which side should push/pull and how should communications between client/server work
- Should the client & Server be developed as two seperate projects

I obviously need to get the foundations right , so If someone can point me in the right direction and also point me to where I can find some non complex examples of client/server structure - I'd realy appreciate it.

Question by:pclarke7
  • 3
  • 2
LVL 11

Expert Comment

ID: 39771338
Yes, it would be two separate projects.  There are many variations but the simplest is that the client initiates all communications and the server only responds, never initiates.

So there is a service running on the server that is available at all times. The user interface on the client sends a request and the server responds. That is it! Each time the client wants to query or update, it sends a request and the server responds.  

Here is an example of writing a simple .net service:


Author Comment

ID: 39807512
Thanks MajorBigDeal,
just before I accept and close this can I ask if I develop the server part of my client/server application as a service - how difficult would it be to convert this to a web based service down the line. Would it be a complete re-write or a simple conversion ?

LVL 11

Expert Comment

ID: 39807600
That's a great question.  I'm a little swamped right now, if you don't mind waiting I'd like to try to answer your question next week.   I've only written a few web services but I've written many servers (both services and daemons) so I'm not a super-expert but I do feel entitled to an opinion.
LVL 11

Accepted Solution

MajorBigDeal earned 2000 total points
ID: 39826954
First, thanks for your patience.  Since it seems that you want to create this as a service before you later make it work as a web service, I think there are several different approaches that might work for you.   The first thing I want to do is get some terminology out of the way, please forgive me if this is repetitive for you.  Also, I'm defining these terms the way I use (and think) about them, which might be different from the way someone else thinks about it.

To me, a service is a process that runs outside a user context.  In other words, it runs all the time (generally speaking) and does not require that a user be connected to the machine. This is different from running Excel (for example), if you log out of your account your Excel spreadsheet has to terminate (I know you knew this already).

A web server is a service that primarily uses HTML to interact with the client's browser. IOW, it generally serves pages. Many web pages are useful applications and if someone wants to automate the use of the pages, they will often write code that mimics the way a human would use the the application in that it scans information on the page, fills in textboxes, clicks buttons, and so on.  This is a very cumbersome way for two computers to interact and it is also brittle (easily broken).

So we use web services instead. A web service generally doesn't use HTML, it uses a format designed to facilitate communication between applications rather than between an application and a human. The format I have used in the past is SOAP but I have heard that there are many others.

So lets assume that you have already written a service for use in your bar-coding application and it listens on port 49876 (for example) and uses a message format called ASN.1 which is very compact and binary in nature (very different from XML). So how are we going to make this into a web service using HTTP(S) and SOAP?  There are many approaches, some of which are:

1. Leave the current service intact, and write a brand-new web service that calls the existing service on the backend to avoid having to recode (or port) the working and debugged service.  IOW, the web service acts as a front-end to the older service. This provides an easy transition path (if you need that) because your users can continue using the older service while you test and tweak the new web service. It does have the big drawback of having to maintain two services that use very different techniques.
2. Modify the current service to to make it into a web-service in addition to its current functionality. There is no reason it can't do both.  This avoids having to maintain two services and still allows for an easier transition in that all your users would not all have to convert at the same time. It also allows one set of backend logic to support two different front-ends for the same service, which is more work but could have the beneficial side-effect of improving and clarifying your logic.  

3. Create a brand new web-service and tear down the older service. Copy and paste as much of the application functionality logic from the first service as practicable but other than that, it would be a complete rewrite.  

So after all that, you have probably figured out that the answer to your question: "Rewrite or Conversion?", is not clear-cut.  It depends a lot on what is important to you and what feels right to you.  If it were me, and I did not need a slow transition, and without knowing the details of your situation, I would choose option 3.  I would create a brand-new web-service application, and tear down the older service because I don't want to do double maintenance and have double complexity.    

That said, if you have not written this yet, why not just do it in a web service in the first place? Bite the bullet now to get into the technology you really want rather than double-handling it with two completely different approaches.

Author Closing Comment

ID: 39844538
Thanks MajorBigDeal,
for the effort that you went to , to answer my question. Excellent advice which I will try to adhere to.


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question