亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? clientform.cs

?? 采用.Net Socket技術的在線聊天室
?? CS
字號:
/************************************************************

 ClientForm.cs
 CopyRight 2000-2001
 This is a sample program made by Saurabh Nandu.
 E-mail: saurabh@mastercsharp.com
 Website: http://www.mastercsharp.com
 Socket Chat
Compilation:
csc /t:winexe /out:..\ChatClient.exe ClientForm.cs

11/September/2001
************************************************************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.Net.Sockets;

namespace SocketClient
{
	public delegate void displayMessage(string msg);
	
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox msgViewBox;
		private System.Windows.Forms.TextBox sendBox;
		private System.Windows.Forms.Button sendButton;
		private System.Windows.Forms.Button connectButton;
		private System.Windows.Forms.TextBox usernameBox;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.ListBox userlistBox;
		private System.ComponentModel.Container components = null;
		//Some required Variables
		private string userID, userName;
		//Flag to check if this is the first communication with the server
		bool firstTime=true;
		private TcpClient chatClient;
		private byte[] recByte = new byte[1024];
		private StringBuilder myBuilder;

		//Constructor
		public Form1()
		{
			InitializeComponent();
			myBuilder = new System.Text.StringBuilder();
		}

		//Method use to process incomming messages
		public void GetMsg(IAsyncResult ar)
		{
			int byteCount;
			try
			{
				//Get the number of Bytes received
				byteCount = (chatClient.GetStream()).EndRead(ar);
				//If bytes received is less than 1 it means
				//the server has disconnected
				if(byteCount <1)
				{
					//Close the socket
					Disconnect();
					MessageBox.Show("Disconnected!!");
					return;
				}
				//Send the Server message for parsing
				BuildText(recByte,0,byteCount);
				//Unless its the first time start Asynchronous Read
				//Again
				if(!firstTime)
				{
					AsyncCallback GetMsgCallback = new AsyncCallback(GetMsg);
					(chatClient.GetStream()).BeginRead(recByte,0,1024,GetMsgCallback,this);
				}
			}
			catch(Exception ed)
			{
				Disconnect();
				MessageBox.Show("Exception Occured :"+ed.ToString());
			}
		}

		//Method to Process Server Response
		public void BuildText(byte[] dataByte, int offset, int count)
		{
			//Loop till the number of bytes received
			for(int i=offset; i<(count); i++)
			{
				//If a New Line character is met then
				//skip the loop cycle
				if(dataByte[i]==10)
					continue;
				//Add the Byte to the StringBuilder in Char format
				myBuilder.Append(Convert.ToChar(dataByte[i]));
			}
			char[] spliters ={'@'};
			//Check if this is the first message received
			if(firstTime)
			{
				//Split the string received at the occurance of '@'
				string[] tempString = myBuilder.ToString().Split(spliters);
				//If the Server sent 'sorry' that means there was some error
				//so we just disconnect the client
				if(tempString[0]=="sorry")
				{
					object[] temp = {tempString[1]};
					this.Invoke(new displayMessage(DisplayText),temp);
					Disconnect();
				}
				else
				{
					//Store the Client Guid 
					this.userID = tempString[0];
					//Loop through array of UserNames
					for(int i=1;i<tempString.Length;i++)
					{
						object[] temp = {tempString[i]};
						//Invoke the AddUser method
						//Since we are working on another thread rather than the primary 
						//thread we have to use the Invoke method
						//to call the method that will update the listbox
						this.Invoke(new displayMessage(AddUser),temp);
					}
					//Reset the flag
					firstTime=false;
					//Start the listening process again 
					AsyncCallback GetMsgCallback = new AsyncCallback(GetMsg);
					(chatClient.GetStream()).BeginRead(recByte,0,1024,GetMsgCallback,this);
				}
				
			}
			else
			{
				//Generally all other messages get passed here
				//Check if the Message starts with the ClientID
				//In which case we come to know that its a Server Command
				if(myBuilder.ToString().IndexOf(this.userID)>=0)
				{
					string[] tempString = myBuilder.ToString().Split(spliters);
					//If its connected command then add the user to the ListBox
					if(tempString[1]=="Connected")
					{
						object[] temp = {tempString[2]};
						this.Invoke(new displayMessage(AddUser),temp);
					}
					else if(tempString[1]=="Disconnected")
					{
						//If its disconnected command then remove the 
						//username from the list box
						object[] temp = {tempString[2]};
						this.Invoke(new displayMessage(RemoveUser),temp);
					}
				}
				else
				{
					//For regular messages append a Line terminator
					myBuilder.Append("\r\n");
					object[] temp = {myBuilder.ToString()};
					//Invoke the DisplayText method
					this.Invoke(new displayMessage(DisplayText),temp);
				}
			}
			//Empty the StringBuilder
			myBuilder = new System.Text.StringBuilder();
		}

		//Method to remove the user from the ListBox
		private void RemoveUser(string user)
		{
			if(userlistBox.Items.Contains(user))
				userlistBox.Items.Remove(user);
			//Display the left message
			DisplayText(user+" left chat\r\n");
		}

		//Method to Add a user to the ListBox
		private void AddUser(string user)
		{
			if(!userlistBox.Items.Contains(user))
				userlistBox.Items.Add(user);
			//If not for first time then display a connected message
			if(!firstTime)
				DisplayText(user+" joined chat\r\n");
		}
		
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					Disconnect();
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		
		//Method to send a message to the server
		public void SendText(string msg)
		{
			//Get a StreamWriter 
			System.IO.StreamWriter chatWriter = new System.IO.StreamWriter(chatClient.GetStream());
			chatWriter.WriteLine(msg);
			//Flush the stream
			chatWriter.Flush();
		}

		//Method to Display Text in the TextBox
		public void DisplayText(string msg)
		{
			msgViewBox.AppendText(msg);
		}
		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.connectButton = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.sendBox = new System.Windows.Forms.TextBox();
			this.msgViewBox = new System.Windows.Forms.TextBox();
			this.sendButton = new System.Windows.Forms.Button();
			this.usernameBox = new System.Windows.Forms.TextBox();
			this.userlistBox = new System.Windows.Forms.ListBox();
			this.SuspendLayout();
			// 
			// connectButton
			// 
			this.connectButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.connectButton.Location = new System.Drawing.Point(656, 248);
			this.connectButton.Name = "connectButton";
			this.connectButton.TabIndex = 3;
			this.connectButton.Text = "Connect";
			this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
			// 
			// label1
			// 
			this.label1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(456, 248);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 23);
			this.label1.TabIndex = 6;
			this.label1.Text = "Username";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label2.Location = new System.Drawing.Point(0, 248);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(64, 23);
			this.label2.TabIndex = 7;
			this.label2.Text = "Message";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// sendBox
			// 
			this.sendBox.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.sendBox.Enabled = false;
			this.sendBox.Location = new System.Drawing.Point(64, 248);
			this.sendBox.Name = "sendBox";
			this.sendBox.Size = new System.Drawing.Size(296, 20);
			this.sendBox.TabIndex = 1;
			this.sendBox.Text = "";
			// 
			// msgViewBox
			// 
			this.msgViewBox.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left);
			this.msgViewBox.Multiline = true;
			this.msgViewBox.Name = "msgViewBox";
			this.msgViewBox.ReadOnly = true;
			this.msgViewBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
			this.msgViewBox.Size = new System.Drawing.Size(528, 240);
			this.msgViewBox.TabIndex = 0;
			this.msgViewBox.Text = "";
			// 
			// sendButton
			// 
			this.sendButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.sendButton.Enabled = false;
			this.sendButton.Location = new System.Drawing.Point(368, 248);
			this.sendButton.Name = "sendButton";
			this.sendButton.TabIndex = 2;
			this.sendButton.Text = "Send";
			this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
			// 
			// usernameBox
			// 
			this.usernameBox.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.usernameBox.Location = new System.Drawing.Point(536, 248);
			this.usernameBox.Name = "usernameBox";
			this.usernameBox.Size = new System.Drawing.Size(112, 20);
			this.usernameBox.TabIndex = 5;
			this.usernameBox.Text = "";
			// 
			// userlistBox
			// 
			this.userlistBox.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.userlistBox.Location = new System.Drawing.Point(536, 0);
			this.userlistBox.Name = "userlistBox";
			this.userlistBox.Size = new System.Drawing.Size(200, 238);
			this.userlistBox.TabIndex = 4;
			// 
			// Form1
			// 
			this.AcceptButton = this.connectButton;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(736, 273);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.label2,
																		  this.label1,
																		  this.usernameBox,
																		  this.userlistBox,
																		  this.connectButton,
																		  this.sendButton,
																		  this.sendBox,
																		  this.msgViewBox});
			this.Name = "Form1";
			this.Text = "Form1";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void sendButton_Click(object sender, System.EventArgs e)
		{
			if(sendBox.Text!="")
			{
				//Send Message
				SendText(sendBox.Text);
				sendBox.Text="";
			}
		}
		private void Disconnect()
		{
			if(chatClient!=null)
			{
				chatClient.Close();
				chatClient=null;
			}
			//Reset the Buttons and Variables
			userlistBox.Items.Clear();
			sendButton.Enabled=false;
			connectButton.Text="Connect";
			usernameBox.Enabled=true;
			sendBox.Enabled=false;
			this.AcceptButton=connectButton;
			firstTime=true;
			userID="";
		}

		private void connectButton_Click(object sender, System.EventArgs e)
		{
			//If user Cliked Connect
			if(connectButton.Text=="Connect"&&usernameBox.Text!="")
			{
				try
				{
					//Connect to server
					chatClient = new TcpClient("localhost",5151);
					DisplayText("Connecting to Server ...\r\n");
					//Start Reading
					AsyncCallback GetMsgCallback = new AsyncCallback(GetMsg);
					(chatClient.GetStream()).BeginRead(recByte,0,1024,GetMsgCallback,null);
					//Send the UserName
					SendText(usernameBox.Text);
					this.userName=usernameBox.Text;
					this.Text="Chat Client :"+userName;
					usernameBox.Text="";
					connectButton.Text="Disconnect";
					usernameBox.Enabled=false;
					sendButton.Enabled=true;
					sendBox.Enabled=true;
					this.AcceptButton=sendButton;
				}
				catch
				{
					Disconnect();
					MessageBox.Show("Can't connect to Server...");
				}
			}
			else if(connectButton.Text=="Disconnect")
			{
				Disconnect();
			}	
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产澳门| 国产丶欧美丶日本不卡视频| 久久国产精品99精品国产| 国产sm精品调教视频网站| 在线观看亚洲专区| 久久精品亚洲乱码伦伦中文| 一区二区成人在线视频| 国产一区在线观看视频| 欧美精品自拍偷拍动漫精品| 国产一区二区三区蝌蚪| 中日韩av电影| 青青青伊人色综合久久| 99久久99久久久精品齐齐| 久久品道一品道久久精品| 亚洲成人免费看| 色先锋久久av资源部| 国产日韩精品视频一区| 蜜桃在线一区二区三区| 欧美片网站yy| 亚洲影院免费观看| 色狠狠一区二区三区香蕉| 国产精品你懂的在线欣赏| 国产一区中文字幕| 精品国产91久久久久久久妲己| 香蕉乱码成人久久天堂爱免费| 91网站在线播放| 中文字幕中文字幕在线一区 | 777久久久精品| 一区二区三区在线视频免费观看| 国产91精品欧美| 久久色视频免费观看| 精品在线你懂的| 2023国产精品视频| 国产精品白丝av| 国产欧美一区二区三区鸳鸯浴| 国产精品一区专区| 久久久久久久久久久久久女国产乱| 麻豆精品久久精品色综合| 欧美一区二区三区白人| 免费国产亚洲视频| 日韩欧美一区二区视频| 激情综合色综合久久综合| 26uuu久久综合| 风间由美一区二区av101| 亚洲国产成人一区二区三区| 不卡的av电影在线观看| 亚洲精品国产视频| 欧美日韩亚洲综合在线| 日日噜噜夜夜狠狠视频欧美人| 欧美日本一道本| 久久电影国产免费久久电影| 日韩精品一区二区三区中文不卡| 国产中文一区二区三区| 中文字幕欧美激情一区| 91传媒视频在线播放| 亚洲成a人v欧美综合天堂| 日韩一区二区免费电影| 国产乱对白刺激视频不卡| 综合网在线视频| 欧美日韩色一区| 国产精品99久久久久久有的能看| 亚洲欧美在线视频| 正在播放一区二区| 国产精品中文字幕一区二区三区| 亚洲欧洲一区二区在线播放| 欧美日韩aaa| 国产精品一二三四五| 亚洲免费看黄网站| 日韩精品一区在线观看| 99在线视频精品| 蜜臀av在线播放一区二区三区| 国产无一区二区| 欧美日韩不卡视频| 成人午夜激情视频| 午夜伊人狠狠久久| 久久综合色之久久综合| 欧美性感一类影片在线播放| 精品亚洲aⅴ乱码一区二区三区| 亚洲欧洲精品天堂一级| 日韩欧美电影在线| 欧美专区日韩专区| 成人app下载| 精品亚洲国内自在自线福利| 一区二区三区不卡在线观看| 国产丝袜欧美中文另类| 在线播放91灌醉迷j高跟美女| 国产成a人无v码亚洲福利| 日韩高清在线观看| 亚洲激情校园春色| 国产精品区一区二区三| 日韩欧美激情一区| 欧美美女网站色| 色先锋久久av资源部| 成人涩涩免费视频| 欧美日韩一区高清| av一本久道久久综合久久鬼色| 蜜臀av一区二区在线观看 | 亚洲综合在线视频| 国产精品乱码久久久久久| 欧美电影免费观看完整版 | 99这里只有精品| 国产精品亚洲人在线观看| 美女一区二区视频| 婷婷丁香激情综合| 亚洲午夜精品17c| 亚洲精品国产无天堂网2021| 国产精品色呦呦| 欧美国产一区在线| 久久久91精品国产一区二区精品 | 精品粉嫩aⅴ一区二区三区四区| 欧美另类一区二区三区| 欧美天堂一区二区三区| 欧洲视频一区二区| 欧美伊人久久大香线蕉综合69 | 欧美日韩综合在线免费观看| 色久优优欧美色久优优| 99久久精品国产毛片| 99国产精品视频免费观看| www.亚洲色图.com| 一本大道久久a久久精二百| 91在线国产福利| 日本高清不卡一区| 欧美日韩在线播放三区| 67194成人在线观看| 日韩三级免费观看| 欧美成人a∨高清免费观看| 久久色.com| 国产精品不卡在线| 亚洲在线视频网站| 日韩一区精品视频| 国产一级精品在线| jvid福利写真一区二区三区| 91丨九色丨蝌蚪富婆spa| 欧美在线一区二区| 日韩欧美色综合| 中文在线资源观看网站视频免费不卡| 国产精品伦一区| 亚洲综合清纯丝袜自拍| 毛片av一区二区| 成人av在线看| 欧美日韩综合不卡| 精品久久久久久久久久久久包黑料 | 国产精品久久久久久久久免费相片| 国产精品午夜电影| 午夜亚洲福利老司机| 国产真实乱对白精彩久久| av一区二区不卡| 91精品国产色综合久久久蜜香臀| 久久综合给合久久狠狠狠97色69| 国产精品乱码一区二区三区软件 | 欧美一区二区日韩| 欧美极品少妇xxxxⅹ高跟鞋 | 婷婷中文字幕一区三区| 国产一区高清在线| 一本大道久久a久久精二百| 日韩一区二区电影| 日韩毛片精品高清免费| 免费观看日韩av| 97久久精品人人澡人人爽| 日韩欧美亚洲国产精品字幕久久久| 国产精品青草久久| 日本欧美一区二区| 91网站在线播放| 久久综合国产精品| 婷婷丁香久久五月婷婷| 不卡电影免费在线播放一区| 91精品国产91热久久久做人人 | 久久九九99视频| 天天射综合影视| 成人av动漫网站| 精品美女在线播放| 天天综合色天天| 色综合久久综合网欧美综合网| 欧美精品一区视频| 亚洲一级在线观看| av中文字幕不卡| 久久麻豆一区二区| 日本不卡一二三| 欧美在线你懂的| 综合久久久久久久| 懂色av一区二区三区免费观看| 日韩欧美国产综合| 日韩不卡免费视频| 欧美日韩国产首页在线观看| 中文字幕亚洲欧美在线不卡| 国产久卡久卡久卡久卡视频精品| 欧美精品777| 五月激情综合网| 欧美亚洲国产怡红院影院| 中文字幕视频一区| 99视频一区二区三区| 国产色产综合色产在线视频| 黑人巨大精品欧美黑白配亚洲| 欧美一区二区日韩| 蜜桃视频在线观看一区二区| 91麻豆精品国产91久久久久久| 亚洲第一成年网| 欧美视频在线一区二区三区| 亚洲精品久久7777| 91久久久免费一区二区|