/// <summary> /// 创建Socket,重复创建会释放之前的 /// </summary> public void OpenNewAdbSocket() { if (CurAdbSocket != null) { CurAdbSocket.Dispose(); } try { CurAdbSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { ReceiveTimeout = ConstCodeHelper.DEFAULT_TIMEOUT, SendTimeout = ConstCodeHelper.DEFAULT_TIMEOUT, ReceiveBufferSize = ConstCodeHelper.DEFAULT_COMMAND_BUFFER_SIZE }; CurAdbSocket.Connect(SocketAddress); CurAdbSocket.NoDelay = true; IsOpened = true; } catch (Exception ex) { LoggerManagerSingle.Instance.Error(ex); IsOpened = false; } }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { CurAdbSocket.Close(); CurAdbSocket.Dispose(); }