欢迎来到天天文库
浏览记录
ID:23200066
大小:817.98 KB
页数:84页
时间:2018-11-05
《网络编程-实验报告》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、贵州大学实验报告姓名氺窣氺学号氺氺氺实验组实验时间2015-5-9指导教师蔡丽成绩实验项0名称FTP上传下载器编程实验a的通过本实验掌握C#中FTP上传下载器编程的方法,了解其区别与适用场合。实验要求了解C#的UDP编程方法。实验原理使用.NET请求/响应模型的FtpWebRequest类和FtpWebResponse类实现简单的Web浏览器实5佥环境VisualStudio开发环境实5佥步骤1.设计程序界面。2.实现程序功能。学院:计算机学院专业:软件工程班级:软件123班实5佥容实现简单的Web浏览器,要求使用.NET请求/响应模型的Et
2、pWebRequest类和FtpWebResponse类。实验数据服务器核心代码//FtpServerForm类:usingSystem;usingSystem.Collections.Generic;usingSystem.Globalization;usingSystem.10;usingSystem.Net;usingSystem.Net.Sockets;usingSystem.Threading;usingSystem.Windows.Forms;namespaceFtpServer{publicpartialclassFtpServ
3、erForm:Form{TcpListcncrmyTcpListcncr=null;privateThreadlistenThread;//保存用户名和密码Dictionary4、Address[]ips=Dns.GetHostAddresses(n’’);tbxFtpServerlp.Text=ips[1].ToString();tbxFtpScrvcrPort.Text=”21IstboxStatus.Enabled=false;}//启动服务器privatevoidbtnFtpServerStartStop_Click(objectsender,EventArgse){if(myTcpListener==null){listenThread=newThread(ListenClientConnect);liste5、nThread.IsBackground=true;listenThread.Start();IstboxStatus.Enabled=true;IstboxStatus.Items.Clear();IstboxStatus.Items.Add(”已经启动Ftp月艮务•••n);btnFtpServerStartStop.Text="停止n;}else{myTcpListener.Stop();myTcpListener=null;listenThread.Abort0;IstboxStatus.Items.Add(’’Ftp服务已停止!n)6、;1stboxStatus.Toplndex=IstboxStatus.Items.Count-1;btnFtpServerStartStop.Text="启动”;//监听端口,处理客户端连接privatevoidListenClientConnect(){myTcpListener=newTcpListener(IPAddress.Parse(tbxFtpServerlp.Text),int.Parse(tbxFtpServerPort.Text));//开始监听传入的请求myTcpListener.Start();Addlnfo(”启动F7、TP服务成功!”);AddlnfoC卞tp服务器运行中...[点击”停止“按钮停止FTP服务r);while(true)try//接收连接请求TcpClienttcpClient=myTcpListener.AcceptTcpClient();Addlnfo(string.Format(”客户端({0})与本机({1})建立Ftp连接n,tcpClient.Client.RemoteEndPoint,myTcpListener.LocalEndpoint));Useruser=newUser();user.commandSession=new8、UserSeesion(tcpClient);user.workDir=tbxFtpRoot.Text;Threadt=newThread(UserProcessi
4、Address[]ips=Dns.GetHostAddresses(n’’);tbxFtpServerlp.Text=ips[1].ToString();tbxFtpScrvcrPort.Text=”21IstboxStatus.Enabled=false;}//启动服务器privatevoidbtnFtpServerStartStop_Click(objectsender,EventArgse){if(myTcpListener==null){listenThread=newThread(ListenClientConnect);liste
5、nThread.IsBackground=true;listenThread.Start();IstboxStatus.Enabled=true;IstboxStatus.Items.Clear();IstboxStatus.Items.Add(”已经启动Ftp月艮务•••n);btnFtpServerStartStop.Text="停止n;}else{myTcpListener.Stop();myTcpListener=null;listenThread.Abort0;IstboxStatus.Items.Add(’’Ftp服务已停止!n)
6、;1stboxStatus.Toplndex=IstboxStatus.Items.Count-1;btnFtpServerStartStop.Text="启动”;//监听端口,处理客户端连接privatevoidListenClientConnect(){myTcpListener=newTcpListener(IPAddress.Parse(tbxFtpServerlp.Text),int.Parse(tbxFtpServerPort.Text));//开始监听传入的请求myTcpListener.Start();Addlnfo(”启动F
7、TP服务成功!”);AddlnfoC卞tp服务器运行中...[点击”停止“按钮停止FTP服务r);while(true)try//接收连接请求TcpClienttcpClient=myTcpListener.AcceptTcpClient();Addlnfo(string.Format(”客户端({0})与本机({1})建立Ftp连接n,tcpClient.Client.RemoteEndPoint,myTcpListener.LocalEndpoint));Useruser=newUser();user.commandSession=new
8、UserSeesion(tcpClient);user.workDir=tbxFtpRoot.Text;Threadt=newThread(UserProcessi
此文档下载收益归作者所有