i
i
“K16304” — 2012/11/19 — 9:15
i
i
i
i
i
i
198
SCTP Application Interface
{
int result ,n, i;
fd_set read_fd_set , write_fd_set , exception_fd_set ;
struct timeval timeout ;
struct timeval ∗ to ;
int msecs = −1;
/∗ initialise structures for select ∗ /
n=0;
FD_ZERO(&read_fd_set );
FD_ZERO(&write_fd_set );
FD_ZERO(&exception_fd_set );
if ( msecs < 0)
{ / ∗ select till something comes up ∗ /
t o = NULL ;
}
else if (msecs == 0)
{ / ∗ poll the fd ∗ /
test_dispatch_timer ();
to = &timeout;
timeout . tv_sec = 0;
timeout . tv_usec = 0;
}
else
{ / ∗ set the timer ∗ /
to = &timeout;
timeout . tv_sec = msecs / 1000;
timeout . tv_usec = (msecs % 1000) ∗ 1000;
}
Figure 8.2 test_eventloop function initialization.
The select statement will wait until one of the filedescriptors becomes ready