Dear Sir:<br><br>In an application where the RTSP server has a limit on the number of connections, the server may send something like "RTSP/1.0 406 Not Acceptable\r\n\r\n" and/or close the incoming socket immediately because the max number of connection is reached.
<br><br>If the sample agent openRTSP(VLC, too) connects to the server in the meanwhile, it will be stuck in RTSPClient::getResponse()1 on Windows while read 0 due to "connectin reset by peer" on Linux.<br><br>So, I step inside RTSPClient::getResponse1() and find the following code causes the problem:
<br><br> <span style="font-weight: bold;">unsigned</span> bytesReadNow = readSocket(...);<br> where readSocket(...) has return type <span style="font-weight: bold;">int</span> and may return <span style="font-weight: bold;">
-1</span> in the above scenario.<br> Such that the condition never holds:<br> if (bytesReadNow <span style="font-weight: bold;">==</span> 0) {<br> envir().setResultMsg("RTSP response was truncated");<br> break;
<br> }<br><br> This is because (unsigned)-1 is greater than zero. At this time, the client agent enters an infinite read loop and causes the CPU fulll load. <br> Thererfore, I suggests to modify the code as the following:
<br><br><span style="font-weight: bold;"> int</span> bytesReadNow = readSocket(...);<br> if (bytesReadNow <span style="font-weight: bold;"><=</span> 0) {<br>
envir().setResultMsg("RTSP response was truncated");<br>
break;<br>
}<br><br> This should ends the probelm.<br><br>BR.<br>Brain Lai<br>