資源描述:
《用c#編寫聊天程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、usingSystem;usingSystem.Drawing;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Windows.Forms;usingSystem.Data;usingSystem.Threading;usingSystem.Net.Sockets;usingSystem.Net;namespaceChat_Server{//////Form1的摘要說(shuō)明。///publicclassForm1:System.Windows.Forms.
2、Form{//////必需的設(shè)計(jì)器變量。///privateSystem.ComponentModel.Containercomponents=null;?staticintlistenport=6666;Socketclientsocket;privateSystem.Windows.Forms.ListBoxlbClients;ArrayListclients;privateSystem.Windows.Forms.Buttonbutton1;Threadclientservice;privateSystem.Windows
3、.Forms.Labellabel1;ThreadthreadListen;publicForm1(){InitializeComponent();}//////清理所有正在使用的資源。///protectedoverridevoidDispose(booldisposing){if(disposing){if(clientservice!=null){clientservice.Abort();}if(threadListen!=null){try{threadListen.Abort();}catch(Exceptionex
4、){threadListen=null;}}if(components!=null){components.Dispose();}}base.Dispose(disposing);}#regionWindows窗體設(shè)計(jì)器生成的代碼//////設(shè)計(jì)器支持所需的方法-不要使用代碼編輯器修改///此方法的內(nèi)容。///privatevoidInitializeComponent(){this.lbClients=newSystem.Windows.Forms.ListBox();this.button1=newSystem.Window
5、s.Forms.Button();this.label1=newSystem.Windows.Forms.Label();this.SuspendLayout();////lbClients//this.lbClients.ItemHeight=12;this.lbClients.Location=newSystem.Drawing.Point(16,24);this.lbClients.Name="lbClients";this.lbClients.Size=newSystem.Drawing.Size(184,268);th
6、is.lbClients.TabIndex=0;////button1//this.button1.Location=newSystem.Drawing.Point(272,56);this.button1.Name="button1";this.button1.TabIndex=1;this.button1.Text="button1";this.button1.Click+=newSystem.EventHandler(this.button1_Click);////label1//this.label1.Location=
7、newSystem.Drawing.Point(240,136);this.label1.Name="label1";this.label1.Size=newSystem.Drawing.Size(120,32);this.label1.TabIndex=2;this.label1.Text="label1";////Form1//this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);this.ClientSize=newSystem.Drawing.Size(368,309);
8、this.Controls.Add(this.label1);this.Controls.Add(this.button1);this.Controls.Add(this.lbClients);this.Name="Form1";this.Text="Form1