From c44b10e4447e84dbdfa9105edf460ef364a8f2b3 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 30 十一月 2020 19:53:35 +0800 Subject: [PATCH] Merge branch 'master' into WJC --- HDL_ON/DAL/DriverLayer/Control_TcpClient.cs | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/HDL_ON/DriverLayer/Control_TcpClient.cs b/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs similarity index 93% rename from HDL_ON/DriverLayer/Control_TcpClient.cs rename to HDL_ON/DAL/DriverLayer/Control_TcpClient.cs index f3ad0a0..aa8aeff 100644 --- a/HDL_ON/DriverLayer/Control_TcpClient.cs +++ b/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs @@ -7,6 +7,7 @@ { public class Control_TcpClient { + //澹版槑IP锛岀鍙o紝鍜屼竴涓敤鏉ヨ繛鎺ョ殑Socket public string _ip; @@ -36,10 +37,11 @@ { _tcpClient.Connect(IPAddress.Parse(_ip), _port); Task.Run(new Action(ReceiveMessage));//寮�鍚嚎绋嬶紝涓嶅仠鎺ユ敹娑堟伅 + MainPage.Log($"鎵撳紑tcp client{_ip}:{_port}"); } catch (Exception e) { - Console.WriteLine(e); + MainPage.Log(e.Message); throw; } return true;//杩斿洖杩炴帴鐘舵�� @@ -64,7 +66,11 @@ public void SendMessage(byte[] bytes) { NetworkStream networkStream = _tcpClient.GetStream(); - networkStream.Write(bytes, 0, bytes.Length); + if (networkStream.CanWrite) + { + networkStream.Write(bytes, 0, bytes.Length); + } + //networkStream.Close(); } /// <summary> @@ -119,8 +125,10 @@ // MainPage.Log($"鎺ユ敹鏈嶅姟绔暟鎹�:{tcpDataString}"); //} + } } + } } \ No newline at end of file -- Gitblit v1.8.0