/// <summary> /// Initializes a new instance of the <see cref="Connection"/> class. /// </summary> /// <param name="socket">The socket.</param> /// <param name="encryptor">The encryptor.</param> /// <param name="decryptor">The decryptor.</param> public Connection(Socket socket, IEncryptor encryptor, IDecryptor decryptor) { this.socket = socket; this.remoteEndPoint = socket.RemoteEndPoint; this.encryptor = encryptor; this.decryptor = decryptor; encryptor?.Reset(); decryptor?.Reset(); this.receiveEventArgs = new SocketAsyncEventArgs(); this.receiveEventArgs.SetBuffer(this.buffer, 0, this.buffer.Length); this.receiveEventArgs.Completed += (sender, args) => this.EndReceive(args); }