This separates the select() logic from the socket handling logic, setting up
for a switch to poll().
Partial backport of Core [[https://github.com/bitcoin/bitcoin/pull/14336 | PR14336]]
https://github.com/bitcoin/bitcoin/pull/14336/commits/28211a4bc9c65859b641b81a0541726a0e01988f
Depends on D6460