public virtual void Dispose() { if (_disposing || _disposed) { return; } _disposing = true; _reader = null; _writer = null; if (_stream != null) { _stream.Close(); _stream.Dispose(); _stream = null; } if (_socket != null) { _socket.Close(); _socket.Dispose(); _socket = null; } _disposed = true; }
internal RedisClientBase(Stream incoming, Stream outgoing) : base(RedisSettings.Default) { _executor = new ImmediateExecutor(); _executor.Init(this); _socket = null; _stream = null; _encoder = new ProtocolEncoder(Settings); _reader = new ProtocolReader(Settings, _encoder, incoming); _writer = new ProtocolWriter(Settings, _encoder, outgoing); }
public virtual void Reset() { _disposing = _disposed = false; _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _socket.ReceiveBufferSize = Settings.ReadBufferSize; _socket.SendBufferSize = Settings.WriteBufferSize; _socket.NoDelay = true; // TODO: split timeout settings so both can be set separately _socket.ReceiveTimeout = Settings.ConnectionTimeout; _socket.SendTimeout = Settings.ConnectionTimeout; _socket.Connect(Settings.Host, Settings.Port); _stream = new NetworkStream(_socket, FileAccess.ReadWrite, true); _encoder = new ProtocolEncoder(Settings); _reader = new ProtocolReader(Settings, _encoder, _stream); _writer = new ProtocolWriter(Settings, _encoder, _stream); }