add a select call before each socket read or write so we're aware of the socket status in order to timeout properly