diff --git a/TouchSocket.sln b/TouchSocket.sln
index bd59223af3ff9c617327b4dffd665b9b06f16ef6..1f8cc68975a045c519665ce69100d5ff828398ec 100644
--- a/TouchSocket.sln
+++ b/TouchSocket.sln
@@ -119,7 +119,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LimitNumberOfConnectionsCon
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThrottlingConsoleApp", "examples\BlogsDemos\ThrottlingConsoleApp\ThrottlingConsoleApp.csproj", "{DD7848E5-3489-454E-BF37-49B6FE4C7F01}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrafficCounterConsoleApp", "examples\BlogsDemos\TrafficCounterConsoleApp\TrafficCounterConsoleApp.csproj", "{82A783ED-11AD-407D-990B-A6AE9D557290}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrafficCounterConsoleApp", "examples\BlogsDemos\TrafficCounterConsoleApp\TrafficCounterConsoleApp.csproj", "{82A783ED-11AD-407D-990B-A6AE9D557290}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UDP屏幕捕捉器", "UDP屏幕捕捉器", "{8B9374B5-42D7-48C9-84C7-A560167F0D47}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScreenUdpSender", "examples\Udp简单示例\UDP屏幕捕捉器\ScreenUdpSender\ScreenUdpSender.csproj", "{791D316B-41D7-4B19-A25B-A58EBEA4E04A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScreenUdpReceiver", "examples\Udp简单示例\UDP屏幕捕捉器\ScreenUdpReceiver\ScreenUdpReceiver.csproj", "{EDAA9CD3-1474-4588-9E3B-E970CED20F0F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -259,6 +265,14 @@ Global
{82A783ED-11AD-407D-990B-A6AE9D557290}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82A783ED-11AD-407D-990B-A6AE9D557290}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82A783ED-11AD-407D-990B-A6AE9D557290}.Release|Any CPU.Build.0 = Release|Any CPU
+ {791D316B-41D7-4B19-A25B-A58EBEA4E04A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {791D316B-41D7-4B19-A25B-A58EBEA4E04A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {791D316B-41D7-4B19-A25B-A58EBEA4E04A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {791D316B-41D7-4B19-A25B-A58EBEA4E04A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EDAA9CD3-1474-4588-9E3B-E970CED20F0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EDAA9CD3-1474-4588-9E3B-E970CED20F0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EDAA9CD3-1474-4588-9E3B-E970CED20F0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EDAA9CD3-1474-4588-9E3B-E970CED20F0F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -317,6 +331,9 @@ Global
{8452EA31-F7BB-4897-8881-F3EE3F82049A} = {EB38E883-88AF-4E4C-9DCD-FAEBD8A20968}
{DD7848E5-3489-454E-BF37-49B6FE4C7F01} = {EB38E883-88AF-4E4C-9DCD-FAEBD8A20968}
{82A783ED-11AD-407D-990B-A6AE9D557290} = {EB38E883-88AF-4E4C-9DCD-FAEBD8A20968}
+ {8B9374B5-42D7-48C9-84C7-A560167F0D47} = {F4D798A3-8D65-4750-9552-B02BCE081508}
+ {791D316B-41D7-4B19-A25B-A58EBEA4E04A} = {8B9374B5-42D7-48C9-84C7-A560167F0D47}
+ {EDAA9CD3-1474-4588-9E3B-E970CED20F0F} = {8B9374B5-42D7-48C9-84C7-A560167F0D47}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DB787235-A13A-4A3D-B5A8-5DFEB6511EEE}
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.Designer.cs" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.Designer.cs"
deleted file mode 100644
index 985a25cd01804d25072a3844cae1f55f2515c7e8..0000000000000000000000000000000000000000
--- "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.Designer.cs"
+++ /dev/null
@@ -1,55 +0,0 @@
-namespace ScreenUdpSender
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.timer1 = new System.Windows.Forms.Timer(this.components);
- this.SuspendLayout();
- //
- // timer1
- //
- this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Name = "Form1";
- this.Text = "Sender 感谢若汝棋茗大佬的无私奉献 -xfdl 监听地址127.0.0.1:7789,发送地址127.0.0.1:7790";
- this.Load += new System.EventHandler(this.Form1_Load);
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.Timer timer1;
- }
-}
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Form1.Designer.cs" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Form1.Designer.cs"
similarity index 100%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Form1.Designer.cs"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Form1.Designer.cs"
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Form1.cs" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Form1.cs"
similarity index 83%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Form1.cs"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Form1.cs"
index 95f37f351883b16d92e88b71f44ec8de32096cd5..e5005756deed9d8dfe813e29dc5f959d83f7e98a 100644
--- "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Form1.cs"
+++ "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Form1.cs"
@@ -6,6 +6,9 @@ using TouchSocket.Sockets;
namespace ScreenUdpReceiver
{
+ ///
+ /// 本程序源码由网友“木南白水”提供。
+ ///
public partial class Form1 : Form
{
UdpSession udpSession;
@@ -26,8 +29,8 @@ namespace ScreenUdpReceiver
};
udpSession.Setup(new TouchSocketConfig()
.SetBindIPHost(new IPHost("127.0.0.1:7790"))
- .SetBufferLength(1024 * 1024)
- .SetUdpDataHandlingAdapter(() => { return new UdpPackageAdapter() { MaxPackageSize = 1024 * 1024 }; })
+ .SetBufferLength(1024 * 64)
+ .SetUdpDataHandlingAdapter(() => { return new UdpPackageAdapter() { MaxPackageSize = 1024 * 1024, MTU = 1024 * 10 }; })
).Start();
}
catch (Exception ex)
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Form1.resx" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Form1.resx"
similarity index 100%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Form1.resx"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Form1.resx"
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Program.cs" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Program.cs"
similarity index 100%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/Program.cs"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/Program.cs"
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/ScreenUdpReceiver.csproj" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/ScreenUdpReceiver.csproj"
similarity index 100%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpReceiver/ScreenUdpReceiver.csproj"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpReceiver/ScreenUdpReceiver.csproj"
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.Designer.cs" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.Designer.cs"
new file mode 100644
index 0000000000000000000000000000000000000000..cdd813f384aaaa036fda64a44db144d4d42a39f9
--- /dev/null
+++ "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.Designer.cs"
@@ -0,0 +1,101 @@
+namespace ScreenUdpSender
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.button1 = new System.Windows.Forms.Button();
+ this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
+ this.label1 = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
+ this.SuspendLayout();
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(268, 43);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(150, 46);
+ this.button1.TabIndex = 0;
+ this.button1.Text = "启动";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // numericUpDown1
+ //
+ this.numericUpDown1.Location = new System.Drawing.Point(111, 49);
+ this.numericUpDown1.Maximum = new decimal(new int[] {
+ 20,
+ 0,
+ 0,
+ 0});
+ this.numericUpDown1.Minimum = new decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 0});
+ this.numericUpDown1.Name = "numericUpDown1";
+ this.numericUpDown1.Size = new System.Drawing.Size(134, 38);
+ this.numericUpDown1.TabIndex = 1;
+ this.numericUpDown1.Value = new decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 0});
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(33, 51);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(62, 31);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "FPS:";
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(14F, 31F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1600, 821);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.numericUpDown1);
+ this.Controls.Add(this.button1);
+ this.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
+ this.Name = "Form1";
+ this.Text = "Sender 感谢若汝棋茗大佬的无私奉献 -xfdl 监听地址127.0.0.1:7789,发送地址127.0.0.1:7790";
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.NumericUpDown numericUpDown1;
+ private System.Windows.Forms.Label label1;
+ }
+}
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.cs" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.cs"
similarity index 81%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.cs"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.cs"
index 6c6609ac62e3a6beec675f3538879f174f63abbb..e684f1201445700141352205211c7dcc304787bc 100644
--- "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.cs"
+++ "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.cs"
@@ -3,6 +3,7 @@ using System.Drawing;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
+using System.Threading;
using System.Windows.Forms;
using TouchSocket.Core.ByteManager;
using TouchSocket.Core.Config;
@@ -10,6 +11,9 @@ using TouchSocket.Sockets;
namespace ScreenUdpSender
{
+ ///
+ /// 本程序源码由网友“木南白水”提供。
+ ///
public partial class Form1 : Form
{
UdpSession udpSession;
@@ -18,34 +22,19 @@ namespace ScreenUdpSender
InitializeComponent();
}
- private void Form1_Load(object sender, EventArgs e)
- {
- timer1.Enabled = true;
- try
- {
- udpSession = new UdpSession();
+ Thread m_thread;
- udpSession.Setup(
- new TouchSocketConfig()
- .SetBindIPHost(new IPHost(7789))
- .SetBufferLength(1024 * 1024)
- .SetUdpDataHandlingAdapter(() => { return new UdpPackageAdapter() { MaxPackageSize = 1024 * 1024 }; })
- ).Start();
- }
- catch (Exception ex)
+ private void Tick()
+ {
+ while (true)
{
- MessageBox.Show($"错误:{ex.Message},程序将退出");
- Environment.Exit(0);
+ byte[] byteArray = ImageToByte(getScreen());
+ ByteBlock bb = new ByteBlock(byteArray);
+ udpSession.Send(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7790), bb);
+ Thread.Sleep((int)(1000.0/(int)this.numericUpDown1.Value));
}
}
- private void timer1_Tick(object sender, EventArgs e)
- {
- byte[] byteArray = ImageToByte(getScreen());
- ByteBlock bb = new ByteBlock(byteArray);
- udpSession.Send(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7790), bb);
- }
-
#region 屏幕和光标获取
[DllImport("user32.dll")]
@@ -119,5 +108,29 @@ namespace ScreenUdpSender
return image;
}
#endregion
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ this.button1.Enabled = false;
+ try
+ {
+ udpSession = new UdpSession();
+
+ udpSession.Setup(
+ new TouchSocketConfig()
+ .SetBindIPHost(new IPHost(7789))
+ .SetBufferLength(1024 * 64)
+ .SetUdpDataHandlingAdapter(() => { return new UdpPackageAdapter() { MaxPackageSize = 1024 * 1024, MTU = 1024 * 10 }; })
+ ).Start();
+ m_thread = new Thread(Tick);
+ m_thread.IsBackground = true;
+ m_thread.Start();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"错误:{ex.Message},程序将退出");
+ Environment.Exit(0);
+ }
+ }
}
}
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.resx" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.resx"
similarity index 93%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.resx"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.resx"
index d7310886990e7bb8444fdb1913821dcd4cc42245..f298a7be80982ebd538a05758a03bc827419d418 100644
--- "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Form1.resx"
+++ "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Form1.resx"
@@ -57,7 +57,4 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- 17, 17
-
\ No newline at end of file
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Program.cs" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Program.cs"
similarity index 100%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/Program.cs"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/Program.cs"
diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/ScreenUdpSender.csproj" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/ScreenUdpSender.csproj"
similarity index 100%
rename from "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/ScreenUdpSender/ScreenUdpSender.csproj"
rename to "examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UDP\345\261\217\345\271\225\346\215\225\346\215\211\345\231\250/ScreenUdpSender/ScreenUdpSender.csproj"