/// <summary> /// 构造函数 /// </summary> /// <param name="tcpClientHostConfig"></param> /// <param name="sessionHandle"></param> public TcpClientHost(TcpClientHostConfig tcpClientHostConfig, SessionHandle sessionHandle, ITcpClientLog tcpClientLog , Action<TcpClientToken> connectionToServerSuccessAction = null , Action<Exception> socketErrorAction = null) { _tcpClientHostConfig = tcpClientHostConfig; _iLog = tcpClientLog; _seeesionHandle = sessionHandle; _clientToken = new TcpClientToken(_seeesionHandle, _iLog); SocketErrorAction = socketErrorAction; ConnectionToServerSuccessAction = connectionToServerSuccessAction; }
/// <summary> /// 构造函数 /// </summary> /// <param name="sessionHandle"></param> public TcpClientToken(SessionHandle sessionHandle, ITcpClientLog tcpClientLog) { _sessionHandle = sessionHandle; _iLog = tcpClientLog; _tcpClient = new TcpClient(); //_socket = _tcpClient.Client; buffer = new byte[1024 * 8]; bufferList = new List<byte>(1024 * 8); TimeoutObject = new ManualResetEvent(false); }