/// <summary> /// Attempts the connection with retry /// </summary> /// <param name='retries'> /// Retries. /// </param> /// <param name='timeout'> /// Timeout in seconds /// </param> private void AttemptConnection(int retries = 10, int timeout = 5) { Exception error = null; for (int i = 0; i <= retries; i++) { if (i > 0) { Console.Error.WriteLine("clr: failed to connect to clr server, will retry in " + timeout + " secs, url: " + Url); Thread.Sleep(timeout * 1000); } try { _client = new TcpClient(); _client.Connect(Url.Host, Url.Port); _client.NoDelay = true; _stream = new BufferedDuplexStream(_client.GetStream()); _cin = EndianStreams.ReaderFor(_stream, EndianStreams.Endian.Little); _cout = EndianStreams.WriterFor(_stream, EndianStreams.Endian.Little); return; } catch (Exception e) { _client = null; error = e; } } throw error; }
/// <summary> /// Initializes a new instance of the <see cref="bridge.server.CLRBridgeServerClient"/> class. /// </summary> /// <param name="stream">Stream.</param> public CLRBridgeServerClient(Stream stream, EndPoint endpoint) { _stream = stream; _endpoint = endpoint; _cin = EndianStreams.ReaderFor(stream, EndianStreams.Endian.Little); _cout = EndianStreams.WriterFor(stream, EndianStreams.Endian.Little); }