Data Communication Computer Network 简明教程

Client Server Model

两个远程应用程序进程主要可以使用两种不同的方式进行通信:

Two remote application processes can communicate mainly in two different fashions:

  1. Peer-to-peer: Both remote processes are executing at same level and they exchange data using some shared resource.

  2. Client-Server: One remote process acts as a Client and requests some resource from another application process acting as Server.

在客户机-服务器模型中,任何进程都可以充当服务器或客户机。它并不是机器的类型、机器的大小或计算能力使其成为服务器;而是提供服务的这一能力使一台机器成为服务器。

In client-server model, any process can act as Server or Client. It is not the type of machine, size of the machine, or its computing power which makes it server; it is the ability of serving request that makes a machine a server.

client server

系统可以同时作为服务器和客户机。也就是说,一个进程充当服务器,另一个进程充当客户机。客户端和服务器进程都有可能驻留在同一台机器上。

A system can act as Server and Client simultaneously. That is, one process is acting as Server and another is acting as a client. This may also happen that both client and server processes reside on the same machine.

Communication

客户机-服务器模型中的两个进程可以通过多种方式进行交互:

Two processes in client-server model can interact in various ways:

  1. Sockets

  2. Remote Procedure Calls (RPC)

Sockets

在这种模式中,充当服务器的进程使用一个众所周知的(或客户机已知的)端口打开一个套接字,并等待客户端请求到来。充当客户机的第二个进程也打开一个套接字,但它不是等待传入请求,而是“先请求”。

In this paradigm, the process acting as Server opens a socket using a well-known (or known by client) port and waits until some client request comes. The second process acting as a Client also opens a socket but instead of waiting for an incoming request, the client processes ‘requests first’.

sockets

当服务器收到请求时,它会予以处理。它既可以是信息共享,也可以是资源请求。

When the request is reached to server, it is served. It can either be an information sharing or resource request.

Remote Procedure Call

这是一个进程通过执行过程调用与另一个进程进行交互的机制。一个进程(客户机)调用远程主机上的过程。远程主机上的进程被称为服务器。两个进程都被分配了存根。这种通信以以下方式发生:

This is a mechanism where one process interacts with another by means of procedure calls. One process (client) calls the procedure lying on remote host. The process on remote host is said to be Server. Both processes are allocated stubs. This communication happens in the following way:

  1. The client process calls the client stub. It passes all the parameters pertaining to program local to it.

  2. All parameters are then packed (marshalled) and a system call is made to send them to other side of the network.

  3. Kernel sends the data over the network and the other end receives it.

  4. The remote host passes data to the server stub where it is unmarshalled.

  5. The parameters are passed to the procedure and the procedure is then executed.

  6. The result is sent back to the client in the same manner.