tcp - select in non-blocking design of c code -


in unix network programming stevens et al non-blocking sockets illustrated code making use of select call. same call selects between blocking file descriptors.

my understanding non-blocking design alternative select: instead of being blocked in select call, code loop checking non-blocking descriptors , performing else on top of that. understanding wrong or there enigmatic select call makes inevitable in non-blocking design?

down practicalities, need work large number of tcp sockets putting "personal" timeout on each of them. thought of using non-blocking design , looping through correspondent arrays. appropriate without select?

thank you.

a customizable inactivity timer shouldn't have select() call. maintain array of timers separately, update them on every tick, or every <x> iterations through event loop, reset timer each time associated socket has activity, close when inactivity reaches threshold. that's got nothing whatsoever how handle input/output.

whether or not use select() orthogonal whether use non-blocking sockets. select() isn't there keep blocking on reads, after all. select() is keep blocking when don't want to. (and not on reads: can call select() 0 timeout, , select() won't block either). also, provides mechanism knowing when there's input that's more efficient "iterate on entire set of sockets, trying nonblocking read() on each 1 in turn".


Comments