Copyright © tutorialspoint.com

Client Server Model - Architecture

previous next


Advertisements

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:

Types of Server:

There are two types of servers you can have:

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

Copyright © tutorialspoint.com