-
大小: 239KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2023-07-20
- 語(yǔ)言: C#
- 標(biāo)簽:
資源簡(jiǎn)介
c#局域網(wǎng)通信win10能用最新版本vS2017 根據(jù)飛鴿傳書(shū)修改保留主要功能 能正常通信 傳輸文件

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.IO;
using?System.Linq;
using?System.Net;
using?System.Net.Sockets;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
namespace?Cont_ip
{
????public?class?Protocol
????{
????????//private?IPAddress?recIP?=?null;
????????//private?string?SendFileName?=?““;
????????//private?void?btnSendTo_Click(object?sender?EventArgs?e)
????????//{
????????//????int?RemotePort?=?9999;
????????//????if?(recIP?==?null)
????????//????????return;
????????//????else
????????//????{
????????//????????try
????????//????????{
????????//????????????IPEndPoint?iep?=?new?IPEndPoint(recIP?RemotePort);
????????//????????????Socket?socket1?=?new?Socket(AddressFamily.InterNetwork?SocketType.Stream?ProtocolType.Tcp);
????????//????????????socket1.Connect(iep);
????????//????????????NetworkStream?stream?=?new?NetworkStream(socket1);
????????//????????????//string?control?=?“Message“;
????????//????????????//byte[]?newbyte?=?Encoding.UTF8.GetBytes(control.ToCharArray());
????????//????????????//socket1.Send(newbyte?newbyte.Length?0);
????????//????????????//byte[]?msgsize?=?new?byte[4];
????????//????????????//byte[]?msgbyte?=?Encoding.UTF8.GetBytes(rtbSend.Text.Trim());
????????//????????????//msgsize?=?BitConverter.GetBytes(msgbyte.Length);
????????//????????????//socket1.Send(msgsize?msgsize.Length?0);
????????//????????????//socket1.Send(msgbyte?msgbyte.Length?0);
????????//????????????Send_Message(socket1?“Message“?rtbSend.Text.Trim());
????????//????????????control?=?“Require“;
????????//????????????byte[]?bytes?=?Encoding.UTF8.GetBytes(control.ToCharArray());
????????//????????????socket1.Send(bytes?bytes.Length?0);
????????//????????????byte[]?fileNameSize?=?new?byte[4];
????????//????????????byte[]?sendfileName?=?Encoding.UTF8.GetBytes(Path.GetFileName(SendFileName).ToCharArray());
????????//????????????fileNameSize?=?BitConverter.GetBytes(sendfileName.Length);
????????//????????????socket1.Send(fileNameSize?fileNameSize.Length?0);
????????//????????????socket1.Send(sendfileName?sendfileName.Length?0);
????????//????????????Task.Factory.StartNew(()?=>?ReciveFrom(stream));
????????//????????????this.btnFileName.Text?=?““;
????????//????????????this.rtbSend.Clear();
????????//????????????this.btnFileName.Visible?=?false;
????????//????????}
????????//????????catch
????????//????????{
????????//????????????MessageBox.Show(“fs“);
????????//????????}
????????//????}
????????//}
????????public?void?Send_Data(Socket?socketstring?control?string?Message)
????????{
????????????byte[]?newbyte?=?Encoding.UTF8.GetBytes(control.ToCharArray());
????????????byte[]?msgbyte?=?Encoding.UTF8.GetBytes(Message.ToCharArray());
????????????byte[]?msgsize?=?BitConverter.GetBytes(msgbyte.Length);
????????????socket.Send(newbyte?newbyte.Length?0);//發(fā)送命令
????????????socket.Send(msgsize?msgsize.Length?0);//消息名字
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-01-20?15:56??FastPass\
?????目錄???????????0??2018-01-22?08:57??FastPass\FastPass\
?????目錄???????????0??2018-01-20?15:56??FastPass\FastPass\.vs\
?????目錄???????????0??2018-01-20?15:56??FastPass\FastPass\.vs\FastPass\
?????目錄???????????0??2018-01-20?15:56??FastPass\FastPass\.vs\FastPass\v15\
?????文件???????62976??2018-02-06?17:31??FastPass\FastPass\.vs\FastPass\v15\.suo
?????目錄???????????0??2018-01-20?15:56??FastPass\FastPass\.vs\FastPass\v15\Server\
?????目錄???????????0??2018-02-06?17:31??FastPass\FastPass\.vs\FastPass\v15\Server\sqlite3\
?????文件???????????0??2018-01-20?15:56??FastPass\FastPass\.vs\FastPass\v15\Server\sqlite3\db.lock
?????文件??????593920??2018-02-06?17:31??FastPass\FastPass\.vs\FastPass\v15\Server\sqlite3\storage.ide
?????目錄???????????0??2018-01-22?13:58??FastPass\FastPass\Cont_ip\
?????文件????????2207??2018-01-22?10:01??FastPass\FastPass\Cont_ip\Cont_ip.csproj
?????目錄???????????0??2018-01-22?08:57??FastPass\FastPass\Cont_ip\Properties\
?????文件????????1303??2018-01-22?08:57??FastPass\FastPass\Cont_ip\Properties\AssemblyInfo.cs
?????目錄???????????0??2018-01-22?08:58??FastPass\FastPass\Cont_ip\bin\
?????目錄???????????0??2018-01-22?13:58??FastPass\FastPass\Cont_ip\bin\Debug\
?????文件????????4608??2018-01-22?13:58??FastPass\FastPass\Cont_ip\bin\Debug\Cont_ip.dll
?????文件???????11776??2018-01-22?13:58??FastPass\FastPass\Cont_ip\bin\Debug\Cont_ip.pdb
?????目錄???????????0??2018-03-01?19:59??FastPass\FastPass\Cont_ip\bin\Release\
?????目錄???????????0??2018-01-22?08:57??FastPass\FastPass\Cont_ip\obj\
?????目錄???????????0??2018-01-22?13:58??FastPass\FastPass\Cont_ip\obj\Debug\
?????文件??????????42??2018-01-22?13:58??FastPass\FastPass\Cont_ip\obj\Debug\Cont_ip.csproj.CoreCompileInputs.cache
?????文件?????????287??2018-01-22?13:58??FastPass\FastPass\Cont_ip\obj\Debug\Cont_ip.csproj.FileListAbsolute.txt
?????文件????????4608??2018-01-22?13:58??FastPass\FastPass\Cont_ip\obj\Debug\Cont_ip.dll
?????文件???????11776??2018-01-22?13:58??FastPass\FastPass\Cont_ip\obj\Debug\Cont_ip.pdb
?????文件????????6783??2018-01-22?09:00??FastPass\FastPass\Cont_ip\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????目錄???????????0??2018-03-01?19:59??FastPass\FastPass\Cont_ip\obj\Debug\TempPE\
?????文件???????????0??2018-01-22?08:57??FastPass\FastPass\Cont_ip\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件???????????0??2018-01-22?08:57??FastPass\FastPass\Cont_ip\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件???????????0??2018-01-22?08:57??FastPass\FastPass\Cont_ip\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????文件????????3355??2018-01-22?13:58??FastPass\FastPass\Cont_ip\protocol?.cs
............此處省略38個(gè)文件信息
評(píng)論
共有 條評(píng)論