4 SelectSetInit(SelectSetPtr
const ssp
, const double timeout
)
9 /* Inititalize SelectSet, which will clear the fd_set, the
10 * timeval, and the maxfd and numfds to 0.
12 memset(ssp
, 0, sizeof(SelectSet
));
15 ssp
->timeout
.tv_sec
= l
;
16 ssp
->timeout
.tv_usec
= (long) ((timeout
- i
) * 1000000.0);
23 SelectSetAdd(SelectSetPtr
const ssp
, const int fd
)
26 FD_SET(fd
, &ssp
->fds
);
27 if (ssp
->maxfd
< (fd
+ 1))
28 ssp
->maxfd
= (fd
+ 1);
37 SelectSetRemove(SelectSetPtr
const ssp
, const int fd
)
39 if ((fd
>= 0) && (FD_ISSET(fd
, &ssp
->fds
))) {
40 FD_CLR(fd
, &ssp
->fds
);
41 /* Note that maxfd is left alone, even if maxfd was
42 * this one. That is okay.
46 } /* SelectSetRemove */
51 SelectW(SelectSetPtr ssp
, SelectSetPtr resultssp
)
56 memcpy(resultssp
, ssp
, sizeof(SelectSet
));
57 rc
= select(resultssp
->maxfd
, NULL
, SELECT_TYPE_ARG234
&resultssp
->fds
, NULL
, SELECT_TYPE_ARG5
&resultssp
->timeout
);
58 } while ((rc
< 0) && (errno
== EINTR
));
65 SelectR(SelectSetPtr ssp
, SelectSetPtr resultssp
)
70 memcpy(resultssp
, ssp
, sizeof(SelectSet
));
71 rc
= select(resultssp
->maxfd
, SELECT_TYPE_ARG234
&resultssp
->fds
, NULL
, NULL
, SELECT_TYPE_ARG5
&resultssp
->timeout
);
72 } while ((rc
< 0) && (errno
== EINTR
));