net: add RAII socket and use it instead of bare SOCKET

net: add RAII socket and use it instead of bare SOCKET

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.

情報元 - net: add RAII socket and use it instead of bare SOCKET · bitcoin/[email protected] · GitHub

net: add RAII socket and use it instead of bare SOCKET · bitcoin/bitcoin@ba9d732 · GitHub
スポンサーリンク

シェアする

フォローする

スポンサーリンク

トップへ戻る