question on select.
hello good day.
i have a question about the select()
function.
when should we set timeout parameter
into NULL? what is the difference of
putting timeout (0, 0) OR putting NULL
as parameter?
--
while(1) {
tv.sec = 0;
tv.usec = 0;
sel = select(fd+1, &rdfd, NULL, NULL, &tv);
}
--
--
while(1) {
sel = select(fd+1, &rdfd, NULL, NULL, NULL);
}
--
thanks a lot.
lejanson
Quoted 7 lines · Lejanson C. Go
i have a question about the
select()
function.when should we set timeout parameter
into NULL? what is the difference of
putting timeout (0, 0) OR putting NULL
as parameter?
Passing NULL for the timeout parameter will cause select() to wait indefinitely. It won't return until either one of the descriptors is ready or it's interrupted by a signal. The return value will never be zero (it will return a positive value if a descriptor is ready or -1 if it is interrupted).
Passing a pointer to a zero interval (tv_sec == tv_usec == 0) will cause select() to return immediately, even if no descriptors are ready (in which case, the return value will be zero and all of the descriptor sets will be empty).
Signature · 1 line
Glynn Clements <[email protected]>