<div dir="ltr">I have tested for over 100 hours with instrumentation to confirm the code is being used. <div>This happens during rtsp-over-http and appears to be where the device is not expecting Receiver Reports back on the GET connection.<div><br></div><div>RTPInterface calls the following function in GroupsockHelper.cpp with 500 milliseconds  whenever it sends rtcp Receiver Reports and the buffer has gotten full. Wireshark confirms "TCP zero window"</div><div><br></div><div><pre style="white-space:pre-wrap"><span class="gmail-m_-1005644366012020026gmail-n">Boolean</span> <span class="gmail-m_-1005644366012020026gmail-n">makeSocketBlocking</span><span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-kt">int</span> <span class="gmail-m_-1005644366012020026gmail-n">sock</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-kt">unsigned</span> <span class="gmail-m_-1005644366012020026gmail-n">writeTimeoutInMilliseconds</span><span class="gmail-m_-1005644366012020026gmail-p">)</span> <span class="gmail-m_-1005644366012020026gmail-p">{</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-191"></a>  <span class="gmail-m_-1005644366012020026gmail-n">Boolean</span> <span class="gmail-m_-1005644366012020026gmail-n">result</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-192"></a><span class="gmail-m_-1005644366012020026gmail-cp">#if defined(__WIN32__) || defined(_WIN32)</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-193"></a>  <span class="gmail-m_-1005644366012020026gmail-kt">unsigned</span> <span class="gmail-m_-1005644366012020026gmail-kt">long</span> <span class="gmail-m_-1005644366012020026gmail-n">arg</span> <span class="gmail-m_-1005644366012020026gmail-o">=</span> <span class="gmail-m_-1005644366012020026gmail-mi">0</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-194"></a>  <span class="gmail-m_-1005644366012020026gmail-n">result</span> <span class="gmail-m_-1005644366012020026gmail-o">=</span> <span class="gmail-m_-1005644366012020026gmail-n">ioctlsocket</span><span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-n">sock</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-n">FIONBIO</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-o">&</span><span class="gmail-m_-1005644366012020026gmail-n">arg</span><span class="gmail-m_-1005644366012020026gmail-p">)</span> <span class="gmail-m_-1005644366012020026gmail-o">==</span> <span class="gmail-m_-1005644366012020026gmail-mi">0</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-195"></a><span class="gmail-m_-1005644366012020026gmail-cp">#elif defined(VXWORKS)</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-196"></a>  <span class="gmail-m_-1005644366012020026gmail-kt">int</span> <span class="gmail-m_-1005644366012020026gmail-n">arg</span> <span class="gmail-m_-1005644366012020026gmail-o">=</span> <span class="gmail-m_-1005644366012020026gmail-mi">0</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-197"></a>  <span class="gmail-m_-1005644366012020026gmail-n">result</span> <span class="gmail-m_-1005644366012020026gmail-o">=</span> <span class="gmail-m_-1005644366012020026gmail-n">ioctl</span><span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-n">sock</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-n">FIONBIO</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-kt">int</span><span class="gmail-m_-1005644366012020026gmail-p">)</span><span class="gmail-m_-1005644366012020026gmail-o">&</span><span class="gmail-m_-1005644366012020026gmail-n">arg</span><span class="gmail-m_-1005644366012020026gmail-p">)</span> <span class="gmail-m_-1005644366012020026gmail-o">==</span> <span class="gmail-m_-1005644366012020026gmail-mi">0</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-198"></a><span class="gmail-m_-1005644366012020026gmail-cp">#else</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-199"></a>  <span class="gmail-m_-1005644366012020026gmail-kt">int</span> <span class="gmail-m_-1005644366012020026gmail-n">curFlags</span> <span class="gmail-m_-1005644366012020026gmail-o">=</span> <span class="gmail-m_-1005644366012020026gmail-n">fcntl</span><span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-n">sock</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-n">F_GETFL</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-mi">0</span><span class="gmail-m_-1005644366012020026gmail-p">);</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-200"></a>  <span class="gmail-m_-1005644366012020026gmail-n">result</span> <span class="gmail-m_-1005644366012020026gmail-o">=</span> <span class="gmail-m_-1005644366012020026gmail-n">fcntl</span><span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-n">sock</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-n">F_SETFL</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-n">curFlags</span><span class="gmail-m_-1005644366012020026gmail-o">&</span><span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-o">~</span><span class="gmail-m_-1005644366012020026gmail-n">O_NONBLOCK</span><span class="gmail-m_-1005644366012020026gmail-p">))</span> <span class="gmail-m_-1005644366012020026gmail-o">>=</span> <span class="gmail-m_-1005644366012020026gmail-mi">0</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-201"></a><span class="gmail-m_-1005644366012020026gmail-cp">#endif</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-202"></a>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-203"></a>  <span class="gmail-m_-1005644366012020026gmail-k">if</span> <span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-n">writeTimeoutInMilliseconds</span> <span class="gmail-m_-1005644366012020026gmail-o">></span> <span class="gmail-m_-1005644366012020026gmail-mi">0</span><span class="gmail-m_-1005644366012020026gmail-p">)</span> <span class="gmail-m_-1005644366012020026gmail-p">{</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-204"></a><span class="gmail-m_-1005644366012020026gmail-cp">#ifdef SO_SNDTIMEO</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-205"></a>    <span class="gmail-m_-1005644366012020026gmail-k">struct</span> <span class="gmail-m_-1005644366012020026gmail-n">timeval</span> <span class="gmail-m_-1005644366012020026gmail-n">tv</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-206"></a>    <span class="gmail-m_-1005644366012020026gmail-n">tv</span><span class="gmail-m_-1005644366012020026gmail-p">.</span><span class="gmail-m_-1005644366012020026gmail-n">tv_sec</span> <span class="gmail-m_-1005644366012020026gmail-o">=</span> <span class="gmail-m_-1005644366012020026gmail-n">writeTimeoutInMilliseconds</span><span class="gmail-m_-1005644366012020026gmail-o">/</span><span class="gmail-m_-1005644366012020026gmail-mi">100<wbr>0</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-207"></a>    <span class="gmail-m_-1005644366012020026gmail-n">tv</span><span class="gmail-m_-1005644366012020026gmail-p">.</span><span class="gmail-m_-1005644366012020026gmail-n">tv_usec</span> <span class="gmail-m_-1005644366012020026gmail-o">=</span> <span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-n">writeTimeoutInMilliseconds</span><span class="gmail-m_-1005644366012020026gmail-o">%</span><span class="gmail-m_-1005644366012020026gmail-mi">10<wbr>00</span><span class="gmail-m_-1005644366012020026gmail-p">)</span><span class="gmail-m_-1005644366012020026gmail-o">*</span><span class="gmail-m_-1005644366012020026gmail-mi">1000</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-208"></a>    <span class="gmail-m_-1005644366012020026gmail-n">setsockopt</span><span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-n">sock</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-n">SOL_SOCKET</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-n">SO_SNDTIMEO</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-p">(</span><span class="gmail-m_-1005644366012020026gmail-kt">char</span> <span class="gmail-m_-1005644366012020026gmail-o">*</span><span class="gmail-m_-1005644366012020026gmail-p">)</span><span class="gmail-m_-1005644366012020026gmail-o">&</span><span class="gmail-m_-1005644366012020026gmail-n">tv</span><span class="gmail-m_-1005644366012020026gmail-p">,</span> <span class="gmail-m_-1005644366012020026gmail-k">sizeof</span> <span class="gmail-m_-1005644366012020026gmail-n">tv</span><span class="gmail-m_-1005644366012020026gmail-p">);</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-209"></a><span class="gmail-m_-1005644366012020026gmail-cp">#endif</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-210"></a>  <span class="gmail-m_-1005644366012020026gmail-p">}</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-211"></a>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-212"></a>  <span class="gmail-m_-1005644366012020026gmail-k">return</span> <span class="gmail-m_-1005644366012020026gmail-n">result</span><span class="gmail-m_-1005644366012020026gmail-p">;</span>
<a name="m_-1005644366012020026_GroupsockHelper.cpp-213"></a><span class="gmail-m_-1005644366012020026gmail-p">}</span></pre><pre style="white-space:pre-wrap"><span class="gmail-m_-1005644366012020026gmail-p">The setsockopt in windows for SO_SNDTIMEO expects DWORD, an unsigned long.</span></pre><pre style="white-space:pre-wrap"><span class="gmail-m_-1005644366012020026gmail-p">However, timeval is 2 signed longs and the 500ms leaves the first long 0.</span></pre><pre style="white-space:pre-wrap"><span class="gmail-m_-1005644366012020026gmail-p">When Windows sees the 0 it waits FOREVER. </span></pre><pre style="white-space:pre-wrap"><span style="font-family:arial,sans-serif"> </span><br></pre><pre style="white-space:pre-wrap">Test code : <br></pre><pre style="white-space:pre-wrap">Boolean makeSocketBlocking(<wbr>UsageEnvironment& env, int sock, unsigned writeTimeoutInMilliseconds) {
    Boolean result;
#if defined(__WIN32__) || defined(_WIN32)
    unsigned long arg = 0;
    result = ioctlsocket(sock, FIONBIO, &arg) == 0;
#elif defined(VXWORKS)
    int arg = 0;
    result = ioctl(sock, FIONBIO, (int)&arg) == 0;
#else
    int curFlags = fcntl(sock, F_GETFL, 0);
    result = fcntl(sock, F_SETFL, curFlags&(~O_NONBLOCK)) >= 0;
#endif

    int success = 0;
    if (writeTimeoutInMilliseconds > 0) {
#ifdef SO_SNDTIMEO
#if defined(__WIN32__) || defined(_WIN32)
        DWORD msto = (DWORD)<wbr>writeTimeoutInMilliseconds; 
        success = setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&msto, sizeof(msto) );
#else
        struct timeval tv;
        tv.tv_sec = writeTimeoutInMilliseconds/<wbr>1000;
        tv.tv_usec = (writeTimeoutInMilliseconds%<wbr>1000)*1000;
        success = setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof tv);
#endif
        if (success < 0)
            socketErr(env, "Failed to set SO_SNDTIMEO ");
#endif
    }

    return result;
}<br></pre></div><div>(UsageEnvironment arg added to signature only to allow socketErr call.)</div></div></div>