预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共28页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

贵州大学实验报告 学院:计算机学院专业:软件工程班级:软件123班 姓名***学号***实验组实验时间2015-4-18指导教师蔡丽成绩实验项目名称TCP同步编程实验目的通过本实验掌握C#中TCP同步编程的方法,了解其区别与适用场合。 实验要求实现简单的基于TCP或UDP的通信程序(可以基于控制台,也可以基于窗体),要求使用C#的基础Socket。 实验原理通过本实验掌握C#中的网络编程socket同步编程 实验环境Visualstudio2010实验步骤1.设计程序界面。 2.实现程序功能。 实验内容实现简单的基于同步TCP的通信程序,要求使用C#的TCP同步方法。 实验数据核心代码: 服务器的代码 usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Windows.Forms; usingSystem.Net; usingSystem.Net.Sockets; usingSystem.Threading; usingSystem.IO; namespaceSyncTcpServer { publicpartialclassfrmSyncTcpServer:Form { privateIPAddresslocalAddress; privateconstintport=51888; privateTcpListenertcpListener; privateTcpClienttcpClient; privateNetworkStreamnetworkStream; privateBinaryReaderbr; privateBinaryWriterbw; privateintsendCount=1; privateintreceiveCount=10; /*------------声明委托------------*/ //显示消息 privatedelegatevoidShwMsgforViewCallBack(stringstr); privateShwMsgforViewCallBackshwMsgforViewCallBack; //显示状态 privatedelegatevoidShwStatusInfoCallBack(stringstr); privateShwStatusInfoCallBackshwStatusInfoCallBack; //显示进度 privatedelegatevoidShwProgressProcCallBack(intprogress); privateShwProgressProcCallBackshwProgressProcCallBack; //重置消息文本 privatedelegatevoidResetMsgTxtCallBack(); privateResetMsgTxtCallBackresetMsgTxtCallBack; /*------------声明委托------------*/ publicfrmSyncTcpServer() { InitializeComponent(); /*----------定义委托----------*/ //显示消息 shwMsgforViewCallBack=newShwMsgforViewCallBack(ShwMsgforView); //显示状态 shwStatusInfoCallBack=newShwStatusInfoCallBack(ShwStatusInfo); //显示进度 shwProgressProcCallBack=newShwProgressProcCallBack(ShwProgressProc); //重置消息文本 resetMsgTxtCallBack=newResetMsgTxtCallBack(ResetMsgTxt); /*----------定义委托----------*/ IPAddress[]listenIp=Dns.GetHostAddresses(Dns.GetHostName()); localAddress=listenIp[1]; //stringhostname=Dns.GetHostName(); //IPHostEntrylocalhost=Dns.GetHostByName(hostname); //localAddress=localhost.AddressList[0]; tbxSendCount.