資源簡介
- TcpClient : TcpClient類為TCP網絡服務提供客戶端連接,它構建于Socket類之上,以提供較高級別的TCP服務,提供了通過網絡連接、發送和接收數據的簡單方法。
- TcpListener:構建于Socket之上,提供了更高抽象級別的TCP服務,使得程序員能更方便地編寫服務器端應用程序。通常情況下,服務器端應用程序在啟動時將首先綁定本地網絡接口的IP地址和端口號,然后進入偵聽客戶請求的狀態,以便于客戶端應用程序提出顯式請求。
- NetworkStream:提供網絡訪問的基礎數據流。一旦偵聽到有客戶端應用程序請求連接偵聽端口,服務器端應用將接受請求,并建立一個負責與客戶端應用程序通信的信道
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
namespace?Common
{
????///?
????///?定義一個類,所有要發送的內容,都按照這個來
????///?
????public?class?ChatMessage
????{
????????///?
????????///?頭部信息
????????///?
????????public?ChatHeader?header?{?get;?set;?}
????????///?
????????///?信息類型,默認為文本
????????///?
????????public?ChatType?chatType?{?get;?set;?}
????????///?
????????///?內容信息
????????///?
????????public?string?info?{?get;?set;?}
????}
????///?
????///?頭部信息
????///?
????public?class?ChatHeader
????{
????????///?
????????///?id唯一標識
????????///?
????????public?string?id?{?get;?set;?}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.????138240??2019-09-16?23:40??MeChat\.vs\MeChat\v14\.suo
?????文件????????189??2019-09-07?17:41??MeChat\Common\App.config
?????文件???????8192??2019-09-15?23:09??MeChat\Common\bin\Debug\Common.dll
?????文件????????189??2019-09-07?17:41??MeChat\Common\bin\Debug\Common.dll.config
?????文件??????22016??2019-09-15?23:09??MeChat\Common\bin\Debug\Common.pdb
?????文件?????675752??2019-09-08?15:50??MeChat\Common\bin\Debug\Newtonsoft.Json.dll
?????文件?????701978??2019-09-08?15:50??MeChat\Common\bin\Debug\Newtonsoft.Json.xm
?????文件???????1377??2019-09-15?22:04??MeChat\Common\ChatMessage.cs
?????文件???????3231??2019-09-15?23:09??MeChat\Common\Common.csproj
?????文件????????365??2019-09-15?22:56??MeChat\Common\CommonVar.cs
?????文件???????1030??2019-09-15?18:21??MeChat\Common\LogHelper.cs
?????文件????????450??2019-09-08?22:12??MeChat\Common\obj\Debug\Common.csproj.FileListAbsolute.txt
?????文件??????12451??2019-09-08?17:09??MeChat\Common\obj\Debug\Common.csprojResolveAssemblyReference.cache
?????文件???????8192??2019-09-15?23:09??MeChat\Common\obj\Debug\Common.dll
?????文件??????22016??2019-09-15?23:09??MeChat\Common\obj\Debug\Common.pdb
?????文件???????6842??2019-09-15?22:56??MeChat\Common\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件??????????0??2019-09-07?17:41??MeChat\Common\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件??????????0??2019-09-07?17:41??MeChat\Common\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件??????????0??2019-09-07?17:41??MeChat\Common\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????文件????????144??2019-09-08?15:50??MeChat\Common\packages.config
?????文件???????3311??2019-09-15?22:42??MeChat\Common\PackHelper.cs
?????文件???????1320??2019-09-07?17:41??MeChat\Common\Properties\AssemblyInfo.cs
?????文件????????936??2019-09-08?16:37??MeChat\Common\SerializerHelper.cs
?????文件???????1137??2019-09-15?22:21??MeChat\MeChat\App.config
?????文件???????8192??2019-09-15?23:09??MeChat\MeChat\bin\Debug\Common.dll
?????文件??????22016??2019-09-15?23:09??MeChat\MeChat\bin\Debug\Common.pdb
?????文件??????15872??2019-09-15?23:10??MeChat\MeChat\bin\Debug\MeChatClient.exe
?????文件???????1137??2019-09-15?22:21??MeChat\MeChat\bin\Debug\MeChatClient.exe.config
?????文件??????32256??2019-09-15?23:10??MeChat\MeChat\bin\Debug\MeChatClient.pdb
?????文件??????22696??2019-09-16?21:46??MeChat\MeChat\bin\Debug\MeChatClient.vshost.exe
............此處省略136個文件信息
- 上一篇:C#抽獎系統源碼(適合新手學習)
- 下一篇:C#運動控制卡DMC5000系列回零點
評論
共有 條評論