Tutorials Point

  Learning Unix Socket
  Socket Quick Guide
  Socket Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint

  Home     References     Discussion Forums     About TP  

Client Server Model - Architecture

previous next AddThis Social Bookmark Button


Most of the Net Applications use the Client Server architecture. These terms refer to the two processes or two applications which will be communicating with each other to exchange some information. One of the two processes acts as a client process and another process acts as a server.

Client Process:

This is the process which typically makes a request for information. After getting the response this process may terminate or may do some other processing.

For example: Internet Browser works as a client application which sends a request to Web Server to get one HTML web page.

Server Process:

This is the process which takes a request from the clients. After getting a request from the client, this process will do required processing and will gather requested information and will send it to the requestor client. Once done, it becomes ready to serve another client. Server process are always alert and ready to serve incoming requests.

For example: Web Server keeps waiting for requests from Internet Browsers and as soon as it gets any request from a browser, it picks up a requested HTML page and sends it back to that Browser.

Notice that the client needs to know of the existence and the address of the server, but the server does not need to know the address or even the existence of the client prior to the connection being established. Once a connection is established, both sides can send and receive information.

2-tier and 3-tier architectures:

There are two types of client server architectures:

  • 2-tier architectures: In this architecture, client directly interact with the server. This type of architecture may have some security holes and performance problems. Internet Explorer and Web Server works on two tier architecture. Here security problems are resolved using Secure Socket Layer(SSL).

  • 3-tier architectures: In this architecture, one more software sits in between client and server. This middle software is called middleware. Middleware are used to perform all the security checks and load balancing in case of heavy load. A middleware takes all requests from the client and after doing required authentication it passes that request to the server. Then server does required processing and sends response back to the middleware and finally middleware passes this response back to the client. If you want to implement a 3-tier architecture then you can keep any middle ware like Web Logic or WebSphere software in between your Web Server and Web Browsers.

Types of Server:

There are two types of servers you can have:

  • Iterative Server: This is the simplest form of server where a server process serves one client and after completing first request then it takes request from another client. Meanwhile another client keeps waiting.

  • Concurrent Servers: This type of server runs multiple concurrent processes to serve many request at a time. Because one process may take longer and another client can not wait for so long. The simplest way to write a concurrent server under Unix is to fork a child process to handle each client separately.

How to make client:

The system calls for establishing a connection are somewhat different for the client and the server, but both involve the basic construct of a socket. The two processes each establish their own sockets.

The steps involved in establishing a socket on the client side are as follows:

  1. Create a socket with the socket() system call.

  2. Connect the socket to the address of the server using the connect() system call.

  3. Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls.

How to make a server:

The steps involved in establishing a socket on the server side are as follows:

  1. Create a socket with the socket() system call.

  2. Bind the socket to an address using the bind() system call. For a server socket on the Internet, an address consists of a port number on the host machine.

  3. Listen for connections with the listen() system call.

  4. Accept a connection with the accept() system call. This call typically blocks until a client connects with the server.

  5. Send and receive data using the read() and write() system calls.

Client and Server Interaction:

Following is the diagram showing complete Client and Server interaction:

Socket Client Server

previous next Printer Friendly