From e08a444a9d7acea0cf39f50d22d29179f6a59292 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 01 十二月 2020 09:37:11 +0800
Subject: [PATCH] 2020-12-1
---
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