I have a set of TCP sockets with keep-alive (interval 1 min), controlled by a select(2) loop (selecting for read).
select(2)
select() sets a bit in the FDSET that indicates which socket has triggered. Use FD_ISSET macro to determine which socket asked for service.
select()
FDSET