資源簡(jiǎn)介
收藏,不可多得,大牛(匠心十年)寫(xiě)的異步TCP通訊類,優(yōu)雅簡(jiǎn)潔,完美!收藏。附上簡(jiǎn)單調(diào)用例子,可直接編譯運(yùn)行。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Net.Sockets;
using?System.Net;
using?System.Threading;
using?System.Globalization;
namespace?AsyncTcp
{
????///?
????///?異步TCP客戶端
????///?
????public?class?AsyncTcpClient?:?IDisposable
????{
????????#region?Fields
????????private?TcpClient?tcpClient;
????????private?bool?disposed?=?false;
????????private?int?retries?=?0;
????????#endregion
????????#region?Ctors
????????///?
????????///?異步TCP客戶端
????????///?
????????///?遠(yuǎn)端服務(wù)器終結(jié)點(diǎn)
????????public?AsyncTcpClient(IPEndPoint?remoteEP)
????????????:?this(new[]?{?remoteEP.Address?}?remoteEP.Port)
????????{
????????}
????????///?
????????///?異步TCP客戶端
????????///?
????????///?遠(yuǎn)端服務(wù)器終結(jié)點(diǎn)
????????///?本地客戶端終結(jié)點(diǎn)
????????public?AsyncTcpClient(IPEndPoint?remoteEP?IPEndPoint?localEP)
????????????:?this(new[]?{?remoteEP.Address?}?remoteEP.Port?localEP)
????????{
????????}
????????///?
????????///?異步TCP客戶端
????????///?
????????///?遠(yuǎn)端服務(wù)器IP地址
????????///?遠(yuǎn)端服務(wù)器端口
????????public?AsyncTcpClient(IPAddress?remoteIPAddress?int?remotePort)
????????????:?this(new[]?{?remoteIPAddress?}?remotePort)
????????{
????????}
????????///?
????????///?異步TCP客戶端
????????///?
????????///?遠(yuǎn)端服務(wù)器IP地址
????????///?遠(yuǎn)端服務(wù)器端口
????????///?本地客戶端終結(jié)點(diǎn)
????????public?AsyncTcpClient(
??????????IPAddress?remoteIPAddress?int?remotePort?IPEndPoint?localEP)
????????????:?this(new[]?{?remoteIPAddress?}?remotePort?localEP)
????????{
????????}
????????///?
????????///?異步TCP客戶端
????????///?
????????///?遠(yuǎn)端服務(wù)器主機(jī)名
????????///?遠(yuǎn)端服務(wù)器端口
????????public?AsyncTcpClient(string?remoteHostName?int?remotePort)
????????????:?this(Dns.GetHostAddresses(remoteHostName)?remotePort)
????????{
????????}
????????///?
????????///?異步TCP客戶端
????????///?
????????///?遠(yuǎn)端服務(wù)器主機(jī)名
????????///?遠(yuǎn)端服務(wù)器端口
????????///?本地客戶端終結(jié)點(diǎn)
????????public?AsyncTcpClient(
??????????string?remoteHostName?int?remotePort?IPEndPoint?localEP)
????????????:?this(Dns.GetHostAddresses(remoteHostName)?remotePort?localEP)
????????{
????????}
????????///?
????????///?異步TCP客戶端
????????///?
????????///?遠(yuǎn)端服務(wù)器IP地址列表
????????///?遠(yuǎn)端服務(wù)器端口
????????public?AsyncTcpClient(IPAddress[]?remoteIPAddresses?int?remotePort)
????????????:?this(remoteIPAddresses?remotePort?null)
?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2357??2018-03-02?18:32??AsyncTcp\AsyncTcp\AsyncTcp.csproj
?????文件????????227??2018-03-02?18:32??AsyncTcp\AsyncTcp\AsyncTcp.csproj.user
?????文件??????19240??2018-03-03?08:35??AsyncTcp\AsyncTcp\AsyncTcpClient.cs
?????文件??????15685??2018-03-03?08:35??AsyncTcp\AsyncTcp\AsyncTcpServer.cs
?????文件??????18432??2018-03-03?08:58??AsyncTcp\AsyncTcp\bin\Debug\AsyncTcp.dll
?????文件??????38400??2018-03-03?08:58??AsyncTcp\AsyncTcp\bin\Debug\AsyncTcp.pdb
?????文件????????614??2018-03-03?08:58??AsyncTcp\AsyncTcp\obj\Debug\AsyncTcp.csproj.FileListAbsolute.txt
?????文件???????1753??2018-03-03?08:58??AsyncTcp\AsyncTcp\obj\Debug\AsyncTcp.csprojResolveAssemblyReference.cache
?????文件??????18432??2018-03-03?08:58??AsyncTcp\AsyncTcp\obj\Debug\AsyncTcp.dll
?????文件??????38400??2018-03-03?08:58??AsyncTcp\AsyncTcp\obj\Debug\AsyncTcp.pdb
?????文件???????5702??2018-03-03?08:58??AsyncTcp\AsyncTcp\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????1366??2018-03-02?18:31??AsyncTcp\AsyncTcp\Properties\AssemblyInfo.cs
?????文件???????3490??2018-03-02?18:31??AsyncTcp\AsyncTcp.sln
????..A..H.?????42496??2018-03-03?09:17??AsyncTcp\AsyncTcp.suo
?????文件??????18432??2018-03-03?08:58??AsyncTcp\Client\bin\Debug\AsyncTcp.dll
?????文件??????38400??2018-03-03?08:58??AsyncTcp\Client\bin\Debug\AsyncTcp.pdb
?????文件??????11264??2018-03-03?08:58??AsyncTcp\Client\bin\Debug\Client.exe
?????文件??????24064??2018-03-03?08:58??AsyncTcp\Client\bin\Debug\Client.pdb
?????文件??????11600??2018-03-03?09:17??AsyncTcp\Client\bin\Debug\Client.vshost.exe
?????文件????????490??2014-01-13?21:31??AsyncTcp\Client\bin\Debug\Client.vshost.exe.manifest
?????文件???????3883??2018-03-02?18:32??AsyncTcp\Client\Client.csproj
?????文件???????2614??2018-03-03?08:57??AsyncTcp\Client\Form1.cs
?????文件???????4511??2018-03-02?18:33??AsyncTcp\Client\Form1.Designer.cs
?????文件???????5817??2018-03-02?18:33??AsyncTcp\Client\Form1.resx
?????文件???????1336??2018-03-03?09:17??AsyncTcp\Client\obj\x86\Debug\Client.csproj.FileListAbsolute.txt
?????文件????????975??2018-03-03?08:58??AsyncTcp\Client\obj\x86\Debug\Client.csproj.GenerateResource.Cache
?????文件??????11264??2018-03-03?08:58??AsyncTcp\Client\obj\x86\Debug\Client.exe
?????文件????????180??2018-03-03?08:58??AsyncTcp\Client\obj\x86\Debug\Client.Form1.resources
?????文件??????24064??2018-03-03?08:58??AsyncTcp\Client\obj\x86\Debug\Client.pdb
?????文件????????180??2018-03-03?08:58??AsyncTcp\Client\obj\x86\Debug\Client.Properties.Resources.resources
............此處省略61個(gè)文件信息
評(píng)論
共有 條評(píng)論