Client Server Programming Model

Client Server Model Defined

The client-server programming model is a distributed computing architecture that segregates information users (clients) from information providers (servers).

  • A client is an application that needs something like a web page or IP address from a server. Clients may contact a server for this information at any time. Clients are information users.
  • A server is an application that provides information or resources to clients. It needs to be always up and running, waiting for requests from clients.

Client applications communicate only with server applications and vice versa. Clients do not communicate directly with other clients.

An alternative to the client-server architecture is the Peer to Peer (P2P) architecture. In these architectures two or more hosts communicate directly with each other.


Client Server Examples

Example: DHCP Client Server

Here is a very common example of the client-server programming model. The dynamic host configuration protocol (DHCP) is the application responsible for requesting and offering IP addresses.

A DHCP client automatically requests an IP address from a DHCP server when a network is detected. A DHCP client could request a new IP address at any time, so the DHCP server must always be active and ready to respond to client requests. The DHCP server application typically exists in a router, but may also be found running on a network server for larger networks.

dhcp_example.png

I can use an HTTP client running on a PC to control the lights at home. This example shows an HTTP client running on a home lighting control board, which has been configured to monitor a lighting control website running on an Internet web server to determine if lights should be on or off.

I browse to the same lighting control webpage being monitored by the lighting control board, enter my username and password, and now have the ability to change the webpage. The next time the control board checks this webpage it will see the change and control the lights appropriately.

http_example.png

Example: HTTP Client and Server in the Same Local Host

A network host is usually either a client or a server but it is possible for a host to be both. Let’s see an example of this.

My control board may also have an HTTP Server running concurrently with the client. This could be used to serve a simple setup and configuration web page, which would allow me to change the website and log-in information the HTTP client uses to check for lighting control updates.

http_cs.png

Example: Local Network HTTP Server

If you do have an HTTP server running on your embedded device, it could also be used to actually control the device.
This would allow you to eliminate the HTTP client application and Internet web server. At first, this may appear to be the best solution, but looks can be deceiving.

This is probably the easiest solution if the HTTP client is running on the same local network as the lighting control board. Unfortunately, this is not very common.

http_s.png

The ability to control the lights or anything else from a remote location over the internet is a more likely and useful scenario. Accessing a web server on a local network from the Internet can be done, but it’s not a trivial task. Deciding where to locate a web server must be carefully considered.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.