Dear Sir:<br><pre>>That's right - the change you're proposing makes no sense, because <br>>"readSet" should already have the correct socket numbers (and no <br>>others) set, because of the assignment (at the start of the <br>
>"SingleStep()" function:<br>>        fd_set readSet = fReadSet; // make a copy for this select() call<br><br>After writing some more debug code to print fds in readSet before/after reset, <br>I found that the readSet before/after reset is logically the same but different physically in order!!!<br>
<br>That's the problem.<br>I found this article describing this issue: <a href="http://blogs.msdn.com/wndp/archive/2006/07/13/664737.aspx">http://blogs.msdn.com/wndp/archive/2006/07/13/664737.aspx</a><br><br>The fReadSet is filled with mixed sockets of UDP/TCP and select() on Windows XP returns <span style="font-size: 10pt; font-family: 'Arial','sans-serif';">WSAENOTSOCK for me!</span><br>
<br>I guess that's why they can be selected individually without problem.<br><br>BTW, not many PCs in my test environments(<10) but I have seen two PCs had the problem.<br><br>PS: the debug code in BasicTaskScheduler::SingleStep() for reference.<br>
<br>{<br> FILE *fp = fopen("c:\\live555.txt", "a");<br> fprintf(fp, "[BasicTaskScheduler::SingleStep()] maximum fd %d, there %d fds in fReadSet while %d ones in readSet\n", fMaxNumSockets - 1, fReadSet.fd_count, readSet.fd_count);<br>
for(size_t i = 0; i < readSet.fd_count; i++)<br> fprintf(fp, "[BasicTaskScheduler::SingleStep()] readSet has fd %d while fReadSet has fd %d\n", readSet.fd_array[i], fReadSet.fd_array[i]);<br>                        <br> int selectResult = select(fMaxNumSockets, &readSet, NULL, NULL, &tv_timeToDelay);<br>
fprintf(fp, "[BasicTaskScheduler::SingleStep()] select(readSet via copy) return %d with err %d\n", selectResult, selectResult < 0 ? WSAGetLastError() : 0);                <br> fclose(fp);<br>}<br><br>{<br> HandlerIterator iter(*fReadHandlers);<br>
HandlerDescriptor* handler;<br> FD_ZERO(&readSet);<br> while ((handler = iter.next()) != NULL)<br> FD_SET((unsigned)handler->socketNum, &readSet);<br>                <br> FILE *fp = fopen("c:\\live555.txt", "a");<br>
fprintf(fp, "[BasicTaskScheduler::SingleStep()] max fd %d, there %d fds in reset fReadSet while %d ones in readSet\n", fMaxNumSockets - 1, fReadSet.fd_count, readSet.fd_count);<br> for(size_t i = 0; i < readSet.fd_count; i++)<br>
fprintf(fp, "[BasicTaskScheduler::SingleStep()] reset readSet has fd %d while fReadSet has fd %d\n", readSet.fd_array[i], fReadSet.fd_array[i]);<br><br> fclose(fp);<br>}<br><br>BR.<br>Brain Lai<br>int selectResult = select(fMaxNumSockets, &readSet, NULL, NULL, &tv_timeToDelay);<br>
{<br> FILE *fp = fopen("c:\\live555.txt", "a");<br> fprintf(fp, "[BasicTaskScheduler::SingleStep()] select(readSet via reset) return %d with err %d\n", selectResult, selectResult < 0 ? WSAGetLastError() : 0);<br>
fclose(fp);<br>}<br></pre>