1 / 5

客户 / 服务器程序

客户 / 服务器程序. 客户程序的典型过程. 调用 socket(…) 创建套接字; 调用 connect(…) 连接到远程的服务器; 调用某个发送数据的系统调用,向服务器发送数据。例如 write(…) ; 调用接收数据的系统调用,从服务器获得响应数据。例如 read(....) ; 完成操作之后,调用 close(…) 关闭套接字。. 服务器程序的典型过程. 调用 socket(…) 创建套接字; 调用 bind(…) 将套接字绑定到某个服务端口; 调用 listen(…) 设置最大等待连接数; 调用 accept(…) 等待新的连接;

jaime-britt
Download Presentation

客户 / 服务器程序

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 客户/服务器程序

  2. 客户程序的典型过程 • 调用socket(…)创建套接字; • 调用connect(…)连接到远程的服务器; • 调用某个发送数据的系统调用,向服务器发送数据。例如write(…); • 调用接收数据的系统调用,从服务器获得响应数据。例如read(....); • 完成操作之后,调用close(…)关闭套接字。

  3. 服务器程序的典型过程 • 调用socket(…)创建套接字; • 调用bind(…)将套接字绑定到某个服务端口; • 调用listen(…)设置最大等待连接数; • 调用accept(…)等待新的连接; • 调用read(…)或其它相似功能的调用接收请求数据; • 根据接收的请求,确定响应信息,并通过write(…)或其它相似功能的调用发送响应数据。

  4. 客户/服务器交互过程 服务器 客户机 socket(…)创建套接字 bind(…)将套接字绑定到某个服务端口 listen(…)设置最大等待连接数 socket(…)创建套接字 accept(…)等待新的连接 connect(…)连接到远程的服务器 write(…) 向服务器发送数据 read(…) 接收请求数据 write(…) 发送响应数据 read(....)从服务器获得响应数据 close(…)关闭套接字 t t

  5. 本节结束

More Related