Squid internal overview Initiating IO Network IO is initiated by requesting for an FD to become ready for reading or writing commSetSelect(fd, COMM_SELECT_{READ,WRITE}, callback, callbackdata, timeout) The callback is called when the FD becomes ready for the requested IO to be performed .. /* Need to read from file descriptor, register interest for this */ commSetSelect(fd, COMM_SELECT_READ, doread, rdata, 0); .. /* in comm_select() each FD is checked for read/write readiness, and the callback is called */ .. void doread(int fd, void *data) { /* This is called when fd is ready to be read from */ /* Do some IO */ /* Now we want to write .. */ commSetSelect(fd, COMM_SELECT_WRITE, dowrite, data, 0); }