| 92 | } |
| 93 | |
| 94 | bool SocketSelector::wait( Time timeout ) { |
| 95 | // Setup the timeout |
| 96 | timeval time; |
| 97 | time.tv_sec = static_cast<long>( timeout.asMicroseconds() / 1000000 ); |
| 98 | time.tv_usec = static_cast<long>( timeout.asMicroseconds() % 1000000 ); |
| 99 | |
| 100 | // Initialize the set that will contain the sockets that are ready |
| 101 | mImpl->SocketsReady = mImpl->AllSockets; |
| 102 | |
| 103 | // Wait until one of the sockets is ready for reading, or timeout is reached |
| 104 | // The first parameter is ignored on Windows |
| 105 | int count = select( mImpl->MaxSocket + 1, &mImpl->SocketsReady, NULL, NULL, |
| 106 | timeout != Time::Zero ? &time : NULL ); |
| 107 | |
| 108 | return count > 0; |
| 109 | } |
| 110 | |
| 111 | bool SocketSelector::isReady( Socket& socket ) const { |
| 112 | SocketHandle handle = socket.getHandle(); |