From 1729c29dedc64d900a1a1c686a56e16fa5417fa1 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Mon, 18 Sep 2017 18:45:51 -0400 Subject: net: split socket creation out of connection Also, check for the correct error during socket creation --- src/netbase.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/netbase.h') diff --git a/src/netbase.h b/src/netbase.h index e7d7bcb375..59945ea97d 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -51,6 +51,7 @@ bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLoo bool Lookup(const char *pszName, std::vector& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions); CService LookupNumeric(const char *pszName, int portDefault = 0); bool LookupSubNet(const char *pszName, CSubNet& subnet); +SOCKET CreateSocket(const CService &addrConnect); bool ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRet, int nTimeout); bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed); /** Return readable error string for a network error code */ -- cgit v1.2.3 From df3bcf89e49ec951baa3778a2452c0d1237ec053 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Mon, 2 Oct 2017 16:37:36 -0400 Subject: 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. --- src/netbase.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/netbase.h') diff --git a/src/netbase.h b/src/netbase.h index 59945ea97d..52e920b3d8 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -52,8 +52,8 @@ bool Lookup(const char *pszName, std::vector& vAddr, int portDefault, CService LookupNumeric(const char *pszName, int portDefault = 0); bool LookupSubNet(const char *pszName, CSubNet& subnet); SOCKET CreateSocket(const CService &addrConnect); -bool ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRet, int nTimeout); -bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed); +bool ConnectSocketDirectly(const CService &addrConnect, const SOCKET& hSocketRet, int nTimeout); +bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed); /** Return readable error string for a network error code */ std::string NetworkErrorString(int err); /** Close socket and set hSocket to INVALID_SOCKET */ -- cgit v1.2.3