public DisplayTcpClient(string remoteIP, int remotePort, int bufferSize = 8192) { client = new AsyncSocketTcpClient(remoteIP, remotePort, bufferSize); client.Connected += Client_Connected; client.Disconnected += Client_Disconnected; client.DataReceived += Client_DataReceived; client.DataSent += Client_DataSent; client.ErrorOccurred += Client_ErrorOccurred; client.Started += Client_Started; client.Stopped += Client_Stopped; this.serverIp = remoteIP; this.serverPort = remotePort; //this.sessionId = client.SessionId; start后成功才能获取到sessionId }
public MOXATcpClient(string remoteIP, int remotePort, int bufferSize = 8192) { client = new AsyncSocketTcpClient(remoteIP, remotePort, bufferSize); client.Connected += Client_Connected; client.Disconnected += Client_Disconnected; client.DataReceived += Client_DataReceived; client.ErrorOccurred += Client_ErrorOccurred; client.Started += Client_Started; client.Stopped += Client_Stopped; this.serverIp = remoteIP; this.serverPort = remotePort; //this.sessionId = client.SessionId; start后成功才能获取到sessionId Thread t = new Thread(() => { ClearSinalMoxta(); }); t.IsBackground = true; t.Start(); }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } this._disposed = true; if (disposing) { //释放托管资源,系统调用时不进来。用于主动释放 this.connectStatus = false; if (this.client != null) { this.client.Dispose(); this.client = null; } this.Connected = null; this.Disconnected = null; } //非托管对象释放,不管是手动还是系统都要执行; Stop(); }