public void TcpClientSend(string send, ref string sendSuccess) { try { if (send.Length == 0) { return; } byte[] bytes = Encoding.Default.GetBytes(send); IntPtr connId = client.ConnectionId; // 发送 if (client.Send(bytes, bytes.Length)) { sendSuccess = send + "信号已输出"; } else { sendSuccess = send + "信号未输出"; } } catch (Exception ex) { //AddMsg(string.Format("$ Send Fail --> msg ({0})", ex.Message)); WriteLog.WriteTextLog(ex, "TCP发送失败", null); } }
public void TcpClientSendByte(byte[] bytes) { try { if (bytes.Length == 0) { return; } // 发送 if (client.Send(bytes, bytes.Length)) { Thread.Sleep(100); WriteLog.WriteTextLog(null, "读取ID号成功", null); } else { WriteLog.WriteTextLog(null, "读取ID号失败", null); } } catch (Exception ex) { //AddMsg(string.Format("$ Send Fail --> msg ({0})", ex.Message)); WriteLog.WriteTextLog(ex, "TCP发送失败", null); } }