資源簡介
窗體異步套接字.rar

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
//要加載的名字空間↓
using?System.Net;
using?System.Net.Sockets;
namespace?客戶端
{
????public?partial?class?Form1?:?Form
????{
????????Socket?clientsocket;
????????string?smsg;
????????byte[]?bmsg?=?new?byte[1024];
????????string?ssmsg;
????????byte[]?bbmsg?=?new?byte[1024];
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????clientsocket?=?new?Socket(AddressFamily.InterNetwork?SocketType.Stream????????????????????????
????????????????????ProtocolType.Tcp);
????????????????IPEndPoint?iep?=?new?IPEndPoint(IPAddress.Parse(“127.0.0.1“)?6000);
????????????????clientsocket.BeginConnect(iep?new?AsyncCallback(callback1)?clientsocket);???????????????????????
????????????}
????????????catch?(Exception?wrong)
????????????{
????????????????MessageBox.Show(string.Format(“錯誤:“?+?wrong));
????????????}
????????}
????????private?void?callback1(IAsyncResult?ar)
????????{
????????????Socket?client?=?(Socket)ar.AsyncState;
????????????try
????????????{
????????????????client.EndConnect(ar);
????????????}
????????????catch
????????????{
????????????????MessageBox.Show(“未連接到服務端,請確認服務端是否開啟!“);
????????????}
????????????client.BeginReceive(bbmsg?0?bbmsg.Length?SocketFlags.None?new?AsyncCallback(callback2)?client);
????????}
????????private?void?callback2(IAsyncResult?ar)
????????{
????????????Socket?client?=?(Socket)ar.AsyncState;
????????????client.EndReceive(ar);
????????????ssmsg?=?Encoding.Default.GetString(bbmsg);
????????????Control.CheckForIllegalCrossThreadCalls?=?false;
????????????this.richTextBox1.Text?+=?ssmsg;
????????????this.richTextBox1.Text?+=?“\n“;
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????smsg?=?textBox1.Text;
????????????bmsg?=?Encoding.Default.GetBytes(smsg);
????????????clientsocket.BeginSend(bmsg?0?bmsg.Length?SocketFlags.None?new?AsyncCallback(callback3)?clientsocket);
????????????textBox1.Text?=?null;
????????}
????????private?void?callback3(IAsyncResult?ar)
????????{
????????????Socket?client?=?(Socket)ar.AsyncState;
????????????client.EndSend(ar);
????????????bmsg?=?new?byte[1024];
????????????client.BeginReceive(bbmsg?0?bbmsg.Length?SocketFlags.None?new?AsyncCallback(callback2)?client);
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????9728??2010-02-17?18:59??窗體異步套接字\客戶端\客戶端\bin\Debug\客戶端.exe
?????文件??????24064??2010-02-17?18:59??窗體異步套接字\客戶端\客戶端\bin\Debug\客戶端.pdb
?????文件??????14328??2010-02-17?18:56??窗體異步套接字\客戶端\客戶端\bin\Debug\客戶端.vshost.exe
?????文件????????490??2007-07-21?01:33??窗體異步套接字\客戶端\客戶端\bin\Debug\客戶端.vshost.exe.manifest
?????文件???????2695??2010-02-17?18:59??窗體異步套接字\客戶端\客戶端\Form1.cs
?????文件???????3123??2010-02-17?10:37??窗體異步套接字\客戶端\客戶端\Form1.Designer.cs
?????文件???????5814??2010-02-17?10:37??窗體異步套接字\客戶端\客戶端\Form1.resx
?????文件????????794??2010-02-17?18:56??窗體異步套接字\客戶端\客戶端\obj\Debug\客戶端.csproj.FileListAbsolute.txt
?????文件????????847??2010-02-17?10:41??窗體異步套接字\客戶端\客戶端\obj\Debug\客戶端.csproj.GenerateResource.Cache
?????文件???????9728??2010-02-17?18:59??窗體異步套接字\客戶端\客戶端\obj\Debug\客戶端.exe
?????文件????????180??2010-02-17?10:42??窗體異步套接字\客戶端\客戶端\obj\Debug\客戶端.Form1.resources
?????文件??????24064??2010-02-17?18:59??窗體異步套接字\客戶端\客戶端\obj\Debug\客戶端.pdb
?????文件????????180??2010-02-17?10:42??窗體異步套接字\客戶端\客戶端\obj\Debug\客戶端.Properties.Resources.resources
?????文件????????490??2010-02-17?10:24??窗體異步套接字\客戶端\客戶端\Program.cs
?????文件???????1374??2010-02-17?10:24??窗體異步套接字\客戶端\客戶端\Properties\AssemblyInfo.cs
?????文件???????2868??2010-02-17?10:24??窗體異步套接字\客戶端\客戶端\Properties\Resources.Designer.cs
?????文件???????5612??2010-02-17?10:24??窗體異步套接字\客戶端\客戶端\Properties\Resources.resx
?????文件???????1094??2010-02-17?10:24??窗體異步套接字\客戶端\客戶端\Properties\Settings.Designer.cs
?????文件????????249??2010-02-17?10:24??窗體異步套接字\客戶端\客戶端\Properties\Settings.settings
?????文件???????3764??2010-02-17?10:42??窗體異步套接字\客戶端\客戶端\客戶端.csproj
?????文件????????917??2010-02-17?10:24??窗體異步套接字\客戶端\客戶端.sln
????..A..H.?????14336??2010-02-17?18:59??窗體異步套接字\客戶端\客戶端.suo
?????文件???????9728??2010-02-17?19:00??窗體異步套接字\服務端\服務端\bin\Debug\服務端.exe
?????文件??????26112??2010-02-17?19:00??窗體異步套接字\服務端\服務端\bin\Debug\服務端.pdb
?????文件??????14328??2010-02-17?18:59??窗體異步套接字\服務端\服務端\bin\Debug\服務端.vshost.exe
?????文件????????490??2007-07-21?01:33??窗體異步套接字\服務端\服務端\bin\Debug\服務端.vshost.exe.manifest
?????文件???????3573??2010-02-17?19:00??窗體異步套接字\服務端\服務端\Form1.cs
?????文件???????2575??2010-02-17?10:22??窗體異步套接字\服務端\服務端\Form1.Designer.cs
?????文件???????5814??2010-02-17?10:22??窗體異步套接字\服務端\服務端\Form1.resx
?????文件????????794??2010-02-17?18:59??窗體異步套接字\服務端\服務端\obj\Debug\服務端.csproj.FileListAbsolute.txt
............此處省略34個文件信息
- 上一篇:Dicom打印服務測試工具
- 下一篇:1024點FFT快速傅立葉變換(vhdl)
評論
共有 條評論