home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Language specific support
Deutsches MediaPortal Forum
Hard- und Software rund um den HTPC
Hardware
TV-Karten
Digital Devices Octopus NET CT/2 Erfahrungen?
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="KayDiefenthal" data-source="post: 1133842" data-attributes="member: 22825"><p>think i had it</p><p></p><p>[code]publicRtspStatusCode SendRequest(RtspRequest request, out RtspResponse response)</p><p>{</p><p>response = null;</p><p>lock (_lockObject)</p><p>{</p><p>NetworkStream stream = null;</p><p>int retryCount = 0;</p><p>while (true)</p><p>{</p><p>try</p><p>{</p><p>if (_client == null)</p><p>{</p><p>_client = newTcpClient(_serverHost, _serverPort);</p><p>}</p><p>}</p><p>catch (Exception ex)</p><p>{</p><p>//this.LogError(ex, "RTSP: failed to connect to server");</p><p>returnRtspStatusCode.RequestTimeOut;</p><p>}</p><p>try</p><p>{</p><p>//this is new </p><p>if ((_client!= null)&&(!_client.Connected))</p><p>{</p><p>_client.Connect(IPAddress.Parse(_serverHost), _serverPort);</p><p>}</p><p>stream = _client.GetStream();</p><p>if (stream == null)</p><p>{</p><p>thrownewException();</p><p>}</p><p>break;</p><p>}</p><p>catch (Exception ex)</p><p>{</p><p>_client.Close();</p><p>_client = null;</p><p>if (retryCount == 1)</p><p>{</p><p>// this.LogError(ex, "RTSP: failed to open stream to server");</p><p>returnRtspStatusCode.RequestTimeOut;</p><p>}</p><p>retryCount++;</p><p>}</p><p>}</p><p>try</p><p>{</p><p>// Send the request and get the response.</p><p>request.Headers.Add("CSeq", _cseq.ToString());</p><p>_cseq++;</p><p>byte[] requestBytes = request.Serialise();</p><p>stream.Write(requestBytes, 0, requestBytes.Length);</p><p>byte[] responseBytes = newbyte[_client.ReceiveBufferSize];</p><p>int byteCount = stream.Read(responseBytes, 0, responseBytes.Length);</p><p>response = RtspResponse.Deserialise(responseBytes, byteCount);</p><p>// Did we get the whole response?</p><p>string contentLengthString;</p><p>int contentLength = 0;</p><p>if (response.Headers.TryGetValue("Content-Length", out contentLengthString))</p><p>{</p><p>contentLength = int.Parse(contentLengthString);</p><p>if ((string.IsNullOrEmpty(response.Body) && contentLength > 0) || response.Body.Length < contentLength)</p><p>{</p><p>if (response.Body == null)</p><p>{</p><p>response.Body = string.Empty;</p><p>}</p><p>while (byteCount > 0 && response.Body.Length < contentLength)</p><p>{</p><p>byteCount = stream.Read(responseBytes, 0, responseBytes.Length);</p><p>response.Body += System.Text.Encoding.UTF8.GetString(responseBytes, 0, byteCount);</p><p>}</p><p>}</p><p>}</p><p>return response.StatusCode;</p><p>}</p><p>finally</p><p>{</p><p>stream.Close();</p><p>}</p><p>}</p><p>}[/code]</p><p> i had add this</p><p>if ((_client!= null)&&(!_client.Connected))</p><p>{</p><p>_client.Connect(IPAddress.Parse(_serverHost), _serverPort);</p><p>}</p><p></p><p></p><p>so recieves it a Response</p></blockquote><p></p>
[QUOTE="KayDiefenthal, post: 1133842, member: 22825"] think i had it [code]publicRtspStatusCode SendRequest(RtspRequest request, out RtspResponse response) { response = null; lock (_lockObject) { NetworkStream stream = null; int retryCount = 0; while (true) { try { if (_client == null) { _client = newTcpClient(_serverHost, _serverPort); } } catch (Exception ex) { //this.LogError(ex, "RTSP: failed to connect to server"); returnRtspStatusCode.RequestTimeOut; } try { //this is new if ((_client!= null)&&(!_client.Connected)) { _client.Connect(IPAddress.Parse(_serverHost), _serverPort); } stream = _client.GetStream(); if (stream == null) { thrownewException(); } break; } catch (Exception ex) { _client.Close(); _client = null; if (retryCount == 1) { // this.LogError(ex, "RTSP: failed to open stream to server"); returnRtspStatusCode.RequestTimeOut; } retryCount++; } } try { // Send the request and get the response. request.Headers.Add("CSeq", _cseq.ToString()); _cseq++; byte[] requestBytes = request.Serialise(); stream.Write(requestBytes, 0, requestBytes.Length); byte[] responseBytes = newbyte[_client.ReceiveBufferSize]; int byteCount = stream.Read(responseBytes, 0, responseBytes.Length); response = RtspResponse.Deserialise(responseBytes, byteCount); // Did we get the whole response? string contentLengthString; int contentLength = 0; if (response.Headers.TryGetValue("Content-Length", out contentLengthString)) { contentLength = int.Parse(contentLengthString); if ((string.IsNullOrEmpty(response.Body) && contentLength > 0) || response.Body.Length < contentLength) { if (response.Body == null) { response.Body = string.Empty; } while (byteCount > 0 && response.Body.Length < contentLength) { byteCount = stream.Read(responseBytes, 0, responseBytes.Length); response.Body += System.Text.Encoding.UTF8.GetString(responseBytes, 0, byteCount); } } } return response.StatusCode; } finally { stream.Close(); } } }[/code] i had add this if ((_client!= null)&&(!_client.Connected)) { _client.Connect(IPAddress.Parse(_serverHost), _serverPort); } so recieves it a Response [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Language specific support
Deutsches MediaPortal Forum
Hard- und Software rund um den HTPC
Hardware
TV-Karten
Digital Devices Octopus NET CT/2 Erfahrungen?
Contact us
RSS
Top
Bottom