- 1、本文档共8页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实 验 报 告
实验名称
Windows Socket 编程
课程名称
计算机网络
实验目的
1.掌握网络应用程序的开发方法;
2.掌握Client/ Server 结构软件的设计与开发方法
3.掌握Socket 机制的工作原理
实验环境
Windows 操作系统,VC 开发环境
实验内容与结果
运行simplex-talk 例程,理解代码并观察现象
Client 端
Server 端
server.exe
[simplex-talk server] server is ready in listening ...
client.exe localhost
[simplex-talk server] received a connection from 127.0.0.1 :
[simplex-talk client] connection to localhost is
ready
[simplex-talk client] please input your message
(empty input to halt):
Hello!
[simplex-talk client] send 7 chars to server
[simplex-talk server] received 7 chars
Hello!
a
[simplex-talk client] send 2 chars to server
[simplex-talk server] received 2 chars
a
[simplex-talk client] empty message is send to server
[simplex-talk client] connection is terminated
[simplex-talk server] empty message is received
[simplex-talk server] connection from 127.0.0.1 is
terminated
从运行过程来看本程序实现了点到点的单向通信,即一端发一端收。
修改simplex-talk 程序,编制duplex-talk 程序,支持client 和server 的双向通信
Duplex-talk 程序运行结果(1)
Client 端
Server 端
erdserver.exe
[duplex-talk server] server is ready in listening ...
erdclient.exe localhost
[duplex-talk server] received a connection from 127.0.0.1 :
[duplex-talk client] connection to localhost is ready
[duplex-talk client] please input your message (empty input to halt)
Hi
[duplex-talk client] send 3 chars to server
[duplex-talk server] received 3 chars
Hi
Got it
[duplex-talk server] send 7 chars to client
[duplex-talk client] received 7 chars
Got it
Bye
[duplex-talk client] send 4 chars to server
[duplex-talk server] received 4 chars
Bye
BYE
[duplex-talk server] send 4 chars to client
[duplex-talk client] received 4 chars
BYE
[duplex-talk client] empty message is send to server
[duplex-talk client] connection is terminated
[duplex-talk server] empty message is received
[duplex-talk server] connection from 127.0.0.1 is terminated
这次我们实现了客户端和服务器之间的双向通信,具体过程是客户端先发起对话,然后服务器与客户端之间交替传递信息。
要实现上述功能,我们将客户端的发送模块加入到了服务器端,将服务器的接收模块加入到了客户端。
3.模拟client 和server 之间的stop-and-wait 的动作
客户
文档评论(0)