public int selectEx(ref UDTSOCKET[] fds, ref UDTSOCKET[] readfds, ref UDTSOCKET[] writefds, ref UDTSOCKET[] exceptfds, Int64 msTimeOut) { Int64 entertime = CClock.getTime(); Int64 to; if (msTimeOut >= 0) to = msTimeOut * 1000; else to = 0xFFFFFFFFFFFFFFFF; // initialize results int count = 0; if (null != readfds) readfds.clear(); if (null != writefds) writefds.clear(); if (null != exceptfds) exceptfds.clear(); do { //for (vector<UDTSOCKET>::const_iterator i = fds.begin(); i != fds.end(); ++ i) foreach (UDTSOCKET i in fds) { UdtSocket s = locate(i); if ((null == s) || s.m_pUDT.m_bBroken || (s.m_Status == UDTSTATUS.CLOSED)) { if (null != exceptfds) { exceptfds.push_back(i); ++count; } continue; } if (null != readfds) { if ((s.m_pUDT.m_bConnected && (s.m_pUDT.m_pRcvBuffer.getRcvDataSize() > 0) && ((s.m_pUDT.m_iSockType == UDT_STREAM) || (s.m_pUDT.m_pRcvBuffer.getRcvMsgNum() > 0))) || (s.m_pUDT.m_bListening && (s.m_pQueuedSockets.size() > 0))) { readfds.push_back(s.m_SocketID); ++count; } } if (null != writefds) { if (s.m_pUDT.m_bConnected && (s.m_pUDT.m_pSndBuffer.getCurrBufSize() < s.m_pUDT.m_iSndBufSize)) { writefds.push_back(s.m_SocketID); ++count; } } } if (count > 0) break; CClock.waitForEvent(); } while (to > CClock.getTime() - entertime); return count; }