Hi Ross,<br><br>So, here is what I found, &quot;WSAGetLastError()&quot; returns WSAENOTSOCK when turnOffBackgroundReadHandling was not called as many times as turnOnBackgroundReadHandling is called.<br>So, my problem was happening only on RTP over TCP, as turnOnBackgroundReadHandling is called <br>
twice for RTCP handling and turnOffBackgroundReadHandling was called only once when clientsession is deleted.<br><br>in OnDemandMediaSubsession.cpp, startPlaying method (line 425),<br><br>RTCPInstance::createNew(..) will call turnOnBackgroundReadHandling as a part of RTCPInstance construction.<br>
and then, if it&#39;s RTCP over TCP, addStreamSocket is called, which will call turnOnBackgroundReadHandling again (for the same socket)<br><br>if (dests-&gt;isTCP) {<br>.. fRTCPInstance-&gt;addStreamSocket(..)<br> &nbsp; <br>
in RTCP.cpp<br><br>void RTCPInstance::addStreamSocket(int sockNum,<br>                                 &nbsp; unsigned char streamChannelId) {<br> &nbsp;// Add the RTCP-over-TCP interface:<br> &nbsp;fRTCPInterface.setStreamSocket(sockNum, streamChannelId);<br><br>
 &nbsp;// Turn on background reading for this socket (in case it&#39;s not on already):<br> &nbsp;TaskScheduler::BackgroundHandlerProc* handler<br> &nbsp; &nbsp;= (TaskScheduler::BackgroundHandlerProc*)&amp;incomingReportHandler;<br> &nbsp;fRTCPInterface.startNetworkReading(handler);<br>
}<br><br>So, my quickest fix was to put the following line<br><br>void RTCPInstance::addStreamSocket(int sockNum,<br>                                 &nbsp; unsigned char streamChannelId) <br>{<br><b> &nbsp;<span style="background-color: rgb(255, 255, 153);">// Turn off the default background read handling created along with RTCPInstance</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);"> &nbsp;fRTCPInterface.stopNetworkReading();</span><br>                                         &nbsp; </b><br> &nbsp;// Add the RTCP-over-TCP interface:<br> &nbsp;fRTCPInterface.setStreamSocket(sockNum, streamChannelId);<br>
<br> &nbsp;// Turn on background reading for this socket<br> &nbsp;TaskScheduler::BackgroundHandlerProc* handler<br> &nbsp; &nbsp;= (TaskScheduler::BackgroundHandlerProc*)&amp;incomingReportHandler;<br> &nbsp;fRTCPInterface.startNetworkReading(handler);<br>
}<br><br>I&#39;m not 100% sure why you have to call &quot;turnOnBackgroundReadHandling&quot; twice for RTP over TCP, but it seems like &quot;turnOnBackgroundReadHandling&quot; should be called after &quot;fRTCPInterface.setStreamSocket(sockNum, streamChannelId)&quot; to handle RTCP over TCP correctly.<br>
<br>--&gt; Also I was just wondering, isn&#39;t fRTCPInterface supposed to be fRTPInterface, since it is actually an instance of RTPInterface,<br><br>I know that I don&#39;t fully understand live555 code at the moment, so, if what I explained above does not make any sense to you then please let me know,<br>
<br>Best Regards,<br>&nbsp;<br>Ken Seo<br><br><br>On Wed, Apr 30, 2008 at 9:01 PM, Ross Finlayson &lt;<a href="mailto:finlayson@live555.com">finlayson@live555.com</a>&gt; wrote:<br>&gt; &gt;Windows error 10038 is &quot;WSAENOTSOCK&quot;, and typically happens when an<br>
&gt; &nbsp;&gt;application is trying to do some socket operation on non-socket or the<br>&gt; &nbsp;&gt;socket that has already been closed, (at least that&#39;s my<br>&gt; &nbsp;&gt;understanding..)<br>&gt; &nbsp;&gt;I was getting this error, from the line in the BasicTaskScheduler.cpp<br>
&gt; &nbsp;&gt;(build 2008-04-03)<br>&gt; &nbsp;&gt;<br>&gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;int err = WSAGetLastError(); &nbsp;// err = 10038<br>&gt; &nbsp;&gt;<br>&gt; &nbsp;&gt;And it only happens when RTSP server tries to delete clientSession due<br>&gt; &nbsp;&gt;to livenessTimeout, (it doesn&#39;t happen when session gets closed by<br>
&gt; &nbsp;&gt;TEARDOWN request).<br>&gt; &nbsp;<br>&gt; &nbsp;That&#39;s odd, because - in each case - the &quot;RTSPClientSession&quot;<br>&gt; &nbsp;destructor will get called, and this should be removing its socket<br>&gt; &nbsp;from the set of active sockets, via the call to<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; envir().taskScheduler().turnOffBackgroundReadHandling(fClientSocket);<br>&gt; &nbsp;on line 271 of &quot;RTSPServer.cpp&quot;.<br>&gt; &nbsp;<br>&gt; &nbsp;So I wonder why this isn&#39;t working for you.<br>&gt; &nbsp;<br>&gt; &nbsp;Please let us know if you can find out anything more about this issue.<br>
&gt; &nbsp;--<br>&gt; &nbsp;<br>&gt; <br>&gt; <br>&gt; &nbsp;Ross Finlayson<br>&gt; &nbsp;Live Networks, Inc.<br>&gt; &nbsp;<a href="http://www.live555.com/">http://www.live555.com/</a><br>&gt; &nbsp;_______________________________________________<br>
&gt; &nbsp;live-devel mailing list<br>&gt; &nbsp;<a href="mailto:live-devel@lists.live555.com">live-devel@lists.live555.com</a><br>&gt; &nbsp;<a href="http://lists.live555.com/mailman/listinfo/live-devel">http://lists.live555.com/mailman/listinfo/live-devel</a><br>
&gt; &nbsp;<br><br>