[toc]
网络编程
客户端-服务器编程模型
在客户端-服务器编程模型中,一个应用由一个服务器进程和一个或多个客户端进程组成。
服务器管理某种资源,并通过操作者这种资源来为它的客户端提供服务。
客户端-服务器模型中的基本操作是事务 (transaction)。
一个 C-S 模型事务由以下四步组成:
- 当一个客户端需要服务时,它向服务器发送一个请求,来发起一个事务。例如,Web 浏览器需要一个文件,那么它发送一个请求给 Web 服务器;
- 服务器收到请求,解释,并以适当方式操作资源;
- 服务器给客户端发送一个响应,并等待下一个请求;
- 客户端收到响应并处理。