aboutsummaryrefslogtreecommitdiff
path: root/src/util/sock.h
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2021-01-04 13:02:43 +0100
committerVasil Dimov <vd@FreeBSD.org>2021-02-10 13:30:08 +0100
commitdec9b5e850c6aad989e814aea5b630b36f55d580 (patch)
tree993908d7a5dfdeb82f365bee1e19084eebd29d31 /src/util/sock.h
parentaa17a44551c03b00a47854438afe9f2f89b6ea74 (diff)
net: move CloseSocket() from netbase to util/sock
Move `CloseSocket()` (and `NetworkErrorString()` which it uses) from `netbase.{h,cpp}` to newly added `src/util/sock.{h,cpp}`. This is necessary in order to use `CloseSocket()` from a newly introduced Sock class (which will live in `src/util/sock.{h,cpp}`). `sock.{h,cpp}` cannot depend on netbase because netbase will depend on it.
Diffstat (limited to 'src/util/sock.h')
-rw-r--r--src/util/sock.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util/sock.h b/src/util/sock.h
new file mode 100644
index 0000000000..0d48235043
--- /dev/null
+++ b/src/util/sock.h
@@ -0,0 +1,18 @@
+// Copyright (c) 2020-2021 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_UTIL_SOCK_H
+#define BITCOIN_UTIL_SOCK_H
+
+#include <compat.h>
+
+#include <string>
+
+/** Return readable error string for a network error code */
+std::string NetworkErrorString(int err);
+
+/** Close socket and set hSocket to INVALID_SOCKET */
+bool CloseSocket(SOCKET& hSocket);
+
+#endif // BITCOIN_UTIL_SOCK_H