/// <summary> /// 私有构造函数。 /// </summary> private AleTunnel(IAleTunnelObserver observer) { this.Observer = observer; this.IsNormal = true; this.IsActive = true; _handshakeTimeoutMgr = new HandshakeTimeoutManager(AleTunnel.HandshakeTimeout, this); }
/// <summary> /// 构造一个客户端使用的TCP连接。 /// </summary> protected AleTunnel(IPAddress clientIP, IPEndPoint serverEndPoint, IAleTunnelObserver observer) : this(observer) { if (clientIP == null || serverEndPoint == null || observer == null) { throw new ArgumentNullException(); } this.LocalEndPoint = new IPEndPoint(clientIP, 0); this.RemoteEndPoint = new IPEndPoint(IPAddress.Parse(serverEndPoint.Address.ToString()), serverEndPoint.Port); this.ID = string.Format("Client_{0}_{1}_{2}", this.LocalEndPoint, this.RemoteEndPoint, Guid.NewGuid()); }
/// <summary> /// 构造一个服务器端使用的TCP连接。 /// </summary> protected AleTunnel(TcpClient client, IAleTunnelObserver observer) : this(observer) { if (client == null || observer == null) { throw new ArgumentNullException(); } this.Client = client; this.InitializeTcpClient(true); this.LocalEndPoint = this.Client.Client.LocalEndPoint as IPEndPoint; this.RemoteEndPoint = this.Client.Client.RemoteEndPoint as IPEndPoint; this.ID = string.Format("Server_{0}_{1}_{2}", this.LocalEndPoint, this.RemoteEndPoint, Guid.NewGuid()); }