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 core#20685 [9/20]
https://github.com/bitcoin/bitcoin/pull/20685/commits/34bcfab562bac9887ca9c3831cf4fd0ee7f9814
Depends on D11017