From d72ca686a3e262693f8a6e45e747e8e8da43335b Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 06 七月 2021 09:39:03 +0800
Subject: [PATCH] 2021-07-06 1.更新
---
HDL_ON/DAL/DriverLayer/Control_TcpClient.cs | 26 ++++++++------------------
1 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs b/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
index 6416b30..aa8aeff 100644
--- a/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
+++ b/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
@@ -7,10 +7,6 @@
{
public class Control_TcpClient
{
- /// <summary>
- /// 閫氳ID
- /// </summary>
- public const int msg_id = 1;
//澹版槑IP锛岀鍙o紝鍜屼竴涓敤鏉ヨ繛鎺ョ殑Socket
public string _ip;
@@ -41,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;//杩斿洖杩炴帴鐘舵��
@@ -69,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>
@@ -124,21 +125,10 @@
// MainPage.Log($"鎺ユ敹鏈嶅姟绔暟鎹�:{tcpDataString}");
//}
+
}
}
- #region A鍗忚
- /// <summary>
- /// 鍙戦�丄鍗忚鏁版嵁
- /// </summary>
- /// <param name="topic"></param>
- public void SendData(string topic)
- {
- string topicString = "Topic:" + topic + "/r/n";
- string lenghtString = "Length:" + "/r/n" + "/r/n";
- }
-
- #endregion
}
}
\ No newline at end of file
--
Gitblit v1.8.0