构造.NET环境下的网页下载器 (2)
时间:2007-01-21 14:05:48
来源: 作者: 点击:次 出处:技术无忧
关键字:构造
三.网页下载器实例介绍: 最后,我就综合以上.NET网络编程的一些知识,向大家展示一个很好的实例。该实例是一个运用Socket的基于同步模式的客户端应用程序,它首先通过解析服务器的IP地址建立一个终结点,同时创建一个基于流套接字的Socket连接,其运用的协议是TCP协议。通过该Socket就可以发送获取网页的命令,再通过该Socket获得服务器上默认的网页,最后通过文件流将获得的数据写入本机文件。这样就完成了网页的下载工作了,程序运行的效果如下所示:
Size(80, 23);
this.label1.TabIndex = 0;
this.label1.Text = "服务器地址:";
this.label1.TextAlign = System.Drawing.
ContentAlignment.MiddleRight;
//
// label2
//
this.label2.Location = new System.Drawing.
Point(16, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.
Size(80, 23);
this.label2.TabIndex = 1;
this.label2.Text = "本地文件名:";
this.label2.TextAlign = System.Drawing.
ContentAlignment.MiddleRight;
//
// Download
//
this.Download.Location = new System.
Drawing.Point(288, 24);
this.Download.Name = "Download";
this.Download.TabIndex = 2;
this.Download.Text = "开始下载";
this.Download.Click += new System.
EventHandler(this.Download_Click);
//
// ServerAddress
//
this.ServerAddress.Location = new System.
Drawing.Point(96, 24);
this.ServerAddress.Name = "ServerAddress";
this.ServerAddress.Size = new System.
Drawing.Size(176, 21);
this.ServerAddress.TabIndex = 3;
this.ServerAddress.Text = "";
//
// Filename 欢迎收藏Pc51.Net技术无忧网











文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面