You are on page 1of 2

Understanding Client-Server Applications -- Part I

Publish Date: Oct 20, 2011 | 119 Ratings | 3.30 out of 5

Overview
Learn the basics of client-server applications and how to develop them. In this Part I of our series on Understanding Client-Server Applications, we discuss the fundamentals of client-server
applications, and explore a simple temperature monitoring application to help you understand what you need to consider when creating a client-server application. In Part II, you learn how to develop
code samples from scratch as we discuss technologies to speed this process.

Table of Contents
1. What is a client-server application?
2. How does a client perform?
3. What is a server's function?
4. Designing a Temperature Monitoring Application
5. Server Considerations
6. Conclusion

1. What is a client-server application?


Client-server describes an application architecture in which the client requests an action or service from the provider of service, the server. Consider a Web browser and a Web server. When you
address a URL in the browser window, it (client) requests a page from a Web server. The server returns an html page to the client, which parses the page (data) and displays it on your computer.
When developing a client-server application, like the Web browser and Web server, you need to consider how you are going to handle developing your application in a team environment and how
you are going to handle long-term maintenance. Developing client-server applications parallels developing modular programs. Modular programming separates large applications into smaller
constituent pieces to ease development in teams and provide better maintainability. In a client-server application, a module does not have to be part of the same program or even run on the same
computer. Each modular function can run on a different device.

2. How does a client perform?


Client programs request service from a server by sending it a message. Referring back to the Web example, a Web browser is a client we use everyday to request Web pages. For example, when
you clicked the link to read this article, your browser sent a message to a Web server in Austin, TX. In response, your browser received the html page you are now reading. A Web browser
represents many client programs, which manage the graphical user interface (GUI) or display portion of an application; determining the presentation of the service provided by an application.

3. What is a server's function?


Server programs process client requests by performing the tasks requested by clients. For example, in a Web browser the Web server returns the html page requested by the client. But client
requests and server programs are not always so simple. Consider a more complicated application in which you buy a product on a Web page. In this case, the client informs the server what you are
purchasing and the server updates a database with the purchase request. Then, the server informs the client that the order has been placed.
Servers are generally passive as they wait for a client request. During these waiting periods servers can perform other tasks or perform maintenance. Unlike the client, the server must continually run
because clients can request service at any time. Clients on the other hand only need to run when they require service. Many server applications allow for multiple clients to request service. For
example, while you are reading this page others interested in client-server programming could also request and read the same Web page.

4. Designing a Temperature Monitoring Application


With a basic understanding of client-server applications, how do you implement this technology for your needs? We touch on a simple application of acquiring temperature readings from a
thermocouple. First we break this application into three modules making the project easier to develop and maintain. The first module acquires the readings from the thermocouple, the second module
analyzes the raw data and relates it to temperature, and the third module provides a graphical user interface or display. Each module must provide data in a format that is understood by the next
module.
After dividing the project into manageable pieces, you have a couple of options. You can write one program to perform all three of these functions on the same computer, or you can distribute the
process over multiple machines by running each of the individual routines or functions on different machines. At this point, you need to consider your goals. For example, you may need a
client-server architecture if you must access the temperature remotely from a different computer than is collecting the temperature data. In this situation, you can create an architecture in which one
computer acquires and analyzes the data and another computer or client queries the data to display it. Figure 1 illustrates how the client and server interact.

Figure 1
The actual architecture of the application depends on your particular needs. If you are acquiring a large number of data points, it may be better to run the acquisition and analysis modules on
separate computers. Thus the display client would request the temperature from the computer processing the raw data, reducing interruptions to the data acquisition process.

5. Server Considerations
In a temperature monitoring application there are certain considerations for designing the server. These include:
Is there more than one client?
Are multiple clients served one-at-a-time or simultaneously?
Are different clients prioritized or treated differently?

1/2

www.ni.com

Are different clients prioritized or treated differently?


In the simplest application, only one remote client requests the temperature from the temperature acquisition computer. In this case the server waits for a request and returns the temperature to the
requesting client.
If multiple clients are serviced, the server continually monitors for service requests. The server queues each request as it is received, ensuring all the clients receive the temperature data they
request. The application queues each client and services it in a first-come-first-serve (First In First Out -- FIFO) manner. Once the queue is empty, the server continues to wait for new clients. The
monitoring process is best broken into two components. One component detects the requests and queues up each client. The second component processes each queued client and performs the
task requested one at a time. In this case, the server returns the temperature.
Processing clients one-at-at-time may be suitable for a simple temperature monitoring application. Simultaneously servicing clients is important for more complicated requests that can take a longer
time, or if you expect a large number of clients. However, client requests still need to be queued however you design the component that processes the actual request. Servicing each client in
different and independent threads or processes can accomplish this.
Some applications require that you give different clients different priorities. A temperature monitoring system can have passive clients, which display the temperature at any given time, and active
clients that query the temperature and process it as part of a larger application. You may need to prioritize the active clients over the passive clients. To do this the server must have a method to
identify, differentiate, and authenticate the clients requesting service.
To be serviced effectively, the client program must work with the interface or protocol defined by the server. The client program for each of the application architectures described is very similar. In
each case the client program must send a temperature request message and must understand the reply from the server. In the case of a server servicing a single remote client or a server servicing
multiple clients in a FIFO manner, the client programs have no noticeable difference in architecture. However, a client program interacting with a server that prioritizes different clients has a request
mechanism that includes parameters for identification and authentication. This could be as simple as adding two parameters to the temperature request message for an ID and a password that the
server can verify.
The server defines the interface for communication between the client and server programs. A well designed interface only exposes how to send messages, what messages are supported, and what
the response to each message is to the client. The server is also developed in a modular fashion, separating the message handling mechanism from the functional component processing the request
itself. Therefore, you can update the functional component of the server without affecting any clients. This modular approach to a client-server application provides a distributed application for remote
temperature monitoring that you can maintain and update without affecting each client and server component.

6. Conclusion
Related Links:
Understanding Client-Server Applications -- Part II

2/2

www.ni.com

You might also like