資源簡(jiǎn)介
P2P通信
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.Net.Sockets;
using?System.Net;
using?System.Threading;
using?System.IO;
namespace?P2P
{
????public?partial?class?Form1?:?Form
????{
????????string?UserName;
????????string?UserIP;
????????string?UserPort;
????????
????????private?p2pdll?p2pdlib?=?new?p2pdll();
????????public?p2pdll.ClassMsg?mySendmsg?=?new?p2pdll.ClassMsg();
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????mySendmsg.type?=?p2pdll.msgType.SendText;
????????????mySendmsg.sendIP?=UserIP;
????????????mySendmsg.sendName?=?UserName;
????????????mySendmsg.sendProt?=?UserPort;
????????????mySendmsg.Data?=?Encoding.Default.GetBytes(this.rtb_msg.Text);
????????????mySendmsg.recIP?=?this.txt_IP.Text;
????????????mySendmsg.recProt?=?UpD_ToPort.Text;
????????????p2pdlib.Send(mySendmsg);
????????????//p2pdlib.Send(this.rtb_msg.Text?this.txt_IP.Text?Convert.ToInt32(this.UpD_ToPort.Text));
????????????this.rtb_AllMsg.AppendText(“給[“?+?mySendmsg.recIP?+?“]?發(fā)送:“?+this.rtb_msg.Text?+?“?\r\n“);
????????}
????????//void?P2P_ReceivMsg(string?msgstr)
????????//{
????????//????if?(this.InvokeRequired)
????????//????{
????????//????????p2pdll.ShowMessage?update?=?new?p2pdll.ShowMessage(this.P2P_ReceivMsg);
????????//????????this.Invoke(update?new?object[]?{?msgstr?});
????????//????}
????????//????else
????????//????{
????????//????????this.rtb_AllMsg.AppendText(msgstr?+?“?\r\n“);
????????//????}
????????//}
????????void?P2P_ReceivMsg(p2pdll.ClassMsg?msgstr)
????????{
????????????if?(this.InvokeRequired)
????????????{
????????????????p2pdll.ShowMessage?update?=?new?p2pdll.ShowMessage(this.P2P_ReceivMsg);
????????????????this.Invoke(update?new?object[]?{?msgstr?});
????????????}
????????????else
????????????{
???
?????????????????if?(msgstr.type?==?p2pdll.msgType.SendText)
????????????????{
????????????????????string?msg?=?“接收到?[“?+?msgstr.sendName?+?“(“?+?msgstr.sendIP?+?“)“?+?“]的消息:“?+?System.Text.Encoding.UTF8.GetString(msgstr.Data);
????????????????????this.rtb_AllMsg.AppendText(msg?+?“?\r\n“);
????????????????}
????????????????else?if?(msgstr.type?==?p2pdll.msgType.SendFile)
????????????????{
????????????????????string?path;
????????????????????string?msg?=?“接收到?[“?+?msgstr.sendName?+?“(“?+?msgstr.sendIP?+?“)“?+?“]?發(fā)過(guò)來(lái)的文件:“?+?msgstr.Filename;
????????????????????if?(MessageBox.Show(msg“確認(rèn)“MessageBoxButtons.YesNo)?==?DialogResult.No)
????????????????????{
????????????????????????return;
????????????????????}
????????????????????path?=?Application.StartupPath?+?“\\“?+?msgstr.Filename;
????????????????????AuthToFile(pathmsgstr.Data);
????????????????????this.rtb_
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2021-01-26?19:02??P2P\
?????文件?????????189??2018-07-25?11:59??P2P\App.config
?????文件???????13981??2018-07-27?08:19??P2P\Form1.Designer.cs
?????文件????????9043??2018-07-27?09:14??P2P\Form1.cs
?????文件????????5817??2018-07-27?08:19??P2P\Form1.resx
?????文件????????4145??2018-07-26?08:41??P2P\P2P.csproj
?????文件?????????228??2018-07-26?08:41??P2P\P2P.csproj.user
?????文件???????17672??2019-02-18?17:08??P2P\P2Pold.zip
?????文件?????????526??2018-07-25?11:59??P2P\Program.cs
?????目錄???????????0??2018-07-25?11:59??P2P\Properties\
?????文件????????1418??2018-07-25?11:59??P2P\Properties\AssemblyInfo.cs
?????文件????????2836??2018-07-25?11:59??P2P\Properties\Resources.Designer.cs
?????文件????????5612??2018-07-25?11:59??P2P\Properties\Resources.resx
?????文件????????1090??2018-07-25?11:59??P2P\Properties\Settings.Designer.cs
?????文件?????????249??2018-07-25?11:59??P2P\Properties\Settings.settings
?????文件????????2355??2018-07-25?13:45??P2P\SocketLib.cs
?????目錄???????????0??2021-01-26?18:51??P2P\bin\
?????目錄???????????0??2021-01-26?18:55??P2P\bin\Debug\
?????文件???????19968??2021-01-26?18:55??P2P\bin\Debug\P2P.exe
?????文件?????????189??2018-07-25?11:59??P2P\bin\Debug\P2P.exe.config
?????文件???????38400??2021-01-26?18:55??P2P\bin\Debug\P2P.pdb
?????目錄???????????0??2021-01-26?18:51??P2P\obj\
?????目錄???????????0??2021-01-26?18:55??P2P\obj\Debug\
?????文件?????????214??2021-01-26?18:51??P2P\obj\Debug\.NETfr
?????文件?????????669??2021-01-26?18:55??P2P\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????7272??2021-01-26?18:55??P2P\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件?????????180??2021-01-26?18:55??P2P\obj\Debug\P2P.Form1.resources
?????文件?????????180??2021-01-26?18:55??P2P\obj\Debug\P2P.Properties.Resources.resources
?????文件??????????42??2021-01-26?18:55??P2P\obj\Debug\P2P.csproj.CoreCompileInputs.cache
?????文件?????????735??2021-01-26?18:55??P2P\obj\Debug\P2P.csproj.FileListAbsolute.txt
?????文件????????1012??2021-01-26?18:55??P2P\obj\Debug\P2P.csproj.GenerateResource.cache
............此處省略7個(gè)文件信息
評(píng)論
共有 條評(píng)論