net: Split socket create/connect
Summary:
- net: split socket creation out of connection
Also, check for the correct error during socket creation
- net: Move IsSelectableSocket check into socket creation
We use select in ConnectSocketDirectly, so this check needs to happen before
that.
IsSelectableSocket will not be relevant after upcoming changes to remove select.
- net: use CreateSocket for binds
- net: pass socket closing responsibility up to caller for outgoing connections
This allows const references to be passed around, making it clear where the
socket may and may not be invalidated.
This is a backport of Core PR11363
Depends on D1870, D1871 and D1873
Test Plan:
make check
Reviewers: #bitcoin_abc, jasonbcox
Reviewed By: #bitcoin_abc, jasonbcox
Subscribers: teamcity
Differential Revision: https://reviews.bitcoinabc.org/D1874