//管理socket的一系列操作 void SocketManager(object sender) { try { TcpBussiness.DelClosSocket(tcp, 120); } catch (Exception ex) { Service.ServiceControl.log.Error(DateTime.Now + "管理socket出现异常!" + ex.ToString()); } }
//回复数据的方法 void SendData(object sender) { try { TcpBussiness.SendCommand(tcp); //TcpBussiness.SendData(tcp); } catch (Exception) { throw; } }
public void Start() { Ts_Init(); if (!IsOpen) { socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Bind(new IPEndPoint(IPAddress.Parse(IP), PORT)); socket.Listen(5000); socket.BeginAccept(new AsyncCallback(OnConnectRequest), socket); IsOpen = true; TcpBussiness.ToQtsd(); } }
//回复数据的方法 void SendData() { while (true) { try { TcpBussiness.SendCommand(tcp); //TcpBussiness.SendData(tcp); } catch (Exception ex) { Service.ServiceControl.log.Error(DateTime.Now + ex.ToString()); } Thread.Sleep(500); } }
//管理socket的一系列操作 void SocketManager(object sender) { TcpBussiness.DelClosSocket(tcp, 60); }