diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2021-04-13 16:31:04 +0200 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2022-05-18 16:40:12 +0200 |
commit | 3ad7de225efce3e76530f56bee8a8f7a75ea0f3c (patch) | |
tree | 0bf931f272414bd820a22acb203e73accb9d4563 /src/util/sock.h | |
parent | 7164e00e1bc4e30e69b38a7ba9c557d4fc5d5f87 (diff) | |
download | bitcoin-3ad7de225efce3e76530f56bee8a8f7a75ea0f3c.tar.xz |
net: add new method Sock::Bind() that wraps bind()
This will help to increase `Sock` usage and make more code mockable.
Diffstat (limited to 'src/util/sock.h')
-rw-r--r-- | src/util/sock.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/sock.h b/src/util/sock.h index 7510482857..6a7840f4e2 100644 --- a/src/util/sock.h +++ b/src/util/sock.h @@ -98,6 +98,12 @@ public: [[nodiscard]] virtual int Connect(const sockaddr* addr, socklen_t addr_len) const; /** + * bind(2) wrapper. Equivalent to `bind(this->Get(), addr, addr_len)`. Code that uses this + * wrapper can be unit tested if this method is overridden by a mock Sock implementation. + */ + [[nodiscard]] virtual int Bind(const sockaddr* addr, socklen_t addr_len) const; + + /** * accept(2) wrapper. Equivalent to `std::make_unique<Sock>(accept(this->Get(), addr, addr_len))`. * Code that uses this wrapper can be unit tested if this method is overridden by a mock Sock * implementation. |