So, you’re moving up into the world of multiple active tcp connections, and you know that you don’t want to poll them, but you haven’t learnt about libevent yet, or even heard of it perhaps. So you’re using select(), and it all seems pretty cool and groovy.
However, there’s a trap! when select returns, remember that it MODIFIES the fdsets, you need to reset the fd sets before each call to select(), and use FD_ISSET after the call to see which fd was hit.
Oh, and most importantly, more than one fd can trigger select to return. So don’t make any assumptions that FD_ISSET will only find a single fd.
Leave a Comment