net: add RAII socket and use it instead of bare SOCKET, add Sock unit tests
Summary:
Introduce a class to manage the lifetime of a socket - when the object that contains the socket goes out of scope, the underlying socket will be closed.
In addition, the new Sock class has a Send(), Recv() and Wait() methods that can be overridden by unit tests to mock the socket operations.
The Wait() method also hides the #ifdef USE_POLL poll() #else select() #endif technique from higher level code.
This is a backport of core#20788 [3/5] and core#21159 (bugfix)
https://github.com/bitcoin/bitcoin/pull/20788/commits/ba9d73268f9585d4b9254adcf54708f88222798b
https://github.com/bitcoin/bitcoin/pull/20788/commits/615ba0eb96cf131364c1ceca9d3dedf006fa1e1c
https://github.com/bitcoin/bitcoin/pull/21159/commits/9cc8e30125df14fe47e21e55ab3bf26f4d416565
Depends on D11004
Test Plan:
ninja all check-all
Run the seeder:
./src/seeder/bitcoin-seeder
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D11005