public Connection(IPAddress address, TransportConfig config, ILogger logger) { Endpoint = address; _config = config; _logger = logger; _tcpClient = new TcpClient(); _tcpClient.Connect(address, _config.Port); Stream stream = _tcpClient.GetStream(); #if DEBUG_STREAM stream = new DebugStream(stream); #endif _outputStream = stream; _inputStream = stream; for (byte idx = 0; idx < STREAMID_MAX; ++idx) { _availableStreamIds.Push(idx); _requestStates[idx].Lock = new object(); } _logger.Debug("Ready'ing connection for {0}", Endpoint); GetOptions(); ReadifyConnection(); _logger.Debug("Connection to {0} is ready", Endpoint); }
public Connection(IPAddress address, TransportConfig config, ILogger logger) { Endpoint = address; _config = config; _logger = logger; _tcpClient = new TcpClient(); _tcpClient.Connect(address, _config.Port); _streaming = config.Streaming; Stream stream = _tcpClient.GetStream(); #if DEBUG_STREAM stream = new DebugStream(stream); #endif _outputStream = stream; _inputStream = stream; for (byte idx = 0; idx < MAX_STREAMID; ++idx) { _availableStreamIds.Push(idx); } // start a new read task Task.Factory.StartNew(ReadNextFrameHeader, _cancellation.Token); // readify the connection _logger.Debug("Readyfying connection for {0}", Endpoint); GetOptions(); ReadifyConnection(); _logger.Debug("Connection to {0} is ready", Endpoint); }