六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

構造.NET環境下的頁面下載器 (2)

[摘要]三.網頁下載器實例介紹:   最后,我就綜合以上.NET網絡編程的一些知識,向大家展示一個很好的實例。該實例是一個運用Socket的基于同步模式的客戶端應用程序,它首先通過解析服務器的IP地址建立一個終結點,同時創建一個基于流套接字的Socket連接,其運用的協議是TCP協議。通過該...
三.網頁下載器實例介紹: 
   
    最后,我就綜合以上.NET網絡編程的一些知識,向大家展示一個很好的實例。該實例是一個運用Socket的基于同步模式的客戶端應用程序,它首先通過解析服務器的IP地址建立一個終結點,同時創建一個基于流套接字的Socket連接,其運用的協議是TCP協議。通過該Socket就可以發送獲取網頁的命令,再通過該Socket獲得服務器上默認的網頁,最后通過文件流將獲得的數據寫入本機文件。這樣就完成了網頁的下載工作了,程序運行的效果如下所示: 
    
   
   
  程序的代碼如下: 
   
  using System; 
  using System.Drawing; 
  using System.Collections; 
  using System.ComponentModel; 
  using System.Windows.Forms; 
  using System.Data; 
  using System.Net; 
  using System.Net.Sockets; 
  using System.Text; 
  using System.IO; 
   
  namespace SocketSample 
  { 
   ///  
   /// Form1 的摘要說明。 
   /// 
 
   
   public class Form1 : System.Windows.Forms.Form 
   { 
   private System.Windows.Forms.Label label1; 
   private System.Windows.Forms.Label label2; 
   private System.Windows.Forms.Button Download; 
   private System.Windows.Forms.TextBox ServerAddress; 
   private System.Windows.Forms.TextBox Filename; 
   ///  
   /// 必需的設計器變量。 
   /// 
 
   private System.ComponentModel.Container 
   components = null; 
   public Form1() 
   { 
   // 
   // Windows 窗體設計器支持所必需的 
   // 
   InitializeComponent(); 
   
   // 
   // TODO: 在 InitializeComponent 
   // 調用后添加任何構造函數代碼 
   } 
   
   ///  
   /// 清理所有正在使用的資源。 
   /// 
 
   protected override void Dispose( bool disposing ) 
   { 
   if( disposing ) 
   { 
   if (components != null) 
   { 
   components.Dispose(); 
   } 
   } 
   base.Dispose( disposing ); 
   } 
   
   #region Windows Form Designer generated code 
   ///  
   /// 設計器支持所需的方法 - 不要使用代碼編輯器修改 
   /// 此方法的內容。 
   /// 
 
   private void InitializeComponent() 
   { 
   this.label1 = new System.Windows. 
   Forms.Label(); 
   this.label2 = new System.Windows. 
   Forms.Label(); 
   this.Download = new System.Windows. 
   Forms.Button(); 
   this.ServerAddress = new System.Windows. 
   Forms.TextBox(); 
   this.Filename = new System.Windows. 
   Forms.TextBox(); 
   this.SuspendLayout(); 
   // 
   // label1 
   // 
   this.label1.Location = new System.Drawing. 
   Point(16, 24); 
   this.label1.Name = "label1"; 
   this.label1.Size = new System.Drawing. 
   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 

[1] [2]  下一頁




主站蜘蛛池模板: 四虎影城库 | 欧美午夜在线 | 色综合天天综久久久噜噜噜久久〔 | 日韩福利影院 | 五月天久久久 | 一级一片一a一片 | 青青视频在线播放 | 雪白丰满丝袜长腿白嫩在线 | 日本高清在线播放一区二区三区 | 最近韩国中文字幕更新 | 一区二区三区在线视频观看 | 青青青在线免费 | 日韩精品资源 | 日韩三级欧美 | 亚洲国产欧美精品 | 中文字幕在线导航 | 伊人干 | 天天干夜夜草 | 日本黄色一级大片 | 羞羞色男人的天堂 | 日本欧美国产精品第一页久久 | 日韩一区三区 | 日日摸日日 | 在线观看亚洲专区 | 日本 欧美 国产 | 欧美偷拍色图 | 青青草视频官网 | 天天曰曰 | 最新欧美一级视频 | 欧美透逼视频 | 青草草| 欧美一级爽快片淫片高清在线观看 | 中国与黑人xxxx视频 | 天天爽天天狼久久久综合 | 性8成人有声小说在线播放 性 色 黄 一级 | 亚洲成人精品 | 特黄毛片| 四虎国产精品免费久久影院 | 亚洲精品456 | 色优久久 | 日本一道高清不卡免费 |