Move `maxWait` out of `InterruptibleRecv()` and rename it to
`MAX_WAIT_FOR_IO` so that it can be reused by other code.
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/20685 | core#20685]] [8/20]
https://github.com/bitcoin/bitcoin/pull/20685/commits/34bcfab562bac9887ca9c3831cf4fd0ee7f9814
Depends on D11017