PRCYCoin  2.0.0.7rc1
P2P Digital Currency
netbase.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2015 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_NETBASE_H
6 #define BITCOIN_NETBASE_H
7 
8 #if defined(HAVE_CONFIG_H)
10 #endif
11 
12 #include "compat.h"
13 #include "netaddress.h"
14 #include "serialize.h"
15 
16 #include <stdint.h>
17 #include <string>
18 #include <vector>
19 
20 extern int nConnectTimeout;
21 extern bool fNameLookup;
22 
24 static const int DEFAULT_CONNECT_TIMEOUT = 5000;
26 static const int DEFAULT_NAME_LOOKUP = true;
27 
28 class proxyType
29 {
30 public:
33 
34  bool IsValid() const { return proxy.IsValid(); }
35 
38 };
39 
40 enum Network ParseNetwork(std::string net);
41 std::string GetNetworkName(enum Network net);
42 void SplitHostPort(std::string in, int& portOut, std::string& hostOut);
43 bool SetProxy(enum Network net, const proxyType &addrProxy);
44 bool GetProxy(enum Network net, proxyType& proxyInfoOut);
45 bool IsProxy(const CNetAddr& addr);
46 bool SetNameProxy(const proxyType &addrProxy);
47 bool HaveNameProxy();
48 bool LookupHost(const char* pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup);
49 bool LookupHost(const char* pszName, CNetAddr& addr, bool fAllowLookup);
50 bool Lookup(const char* pszName, CService& addr, int portDefault, bool fAllowLookup);
51 bool Lookup(const char* pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions);
52 CService LookupNumeric(const char* pszName, int portDefault = 0);
53 bool LookupSubNet(const char* pszName, CSubNet& subnet);
54 bool ConnectSocket(const CService& addr, SOCKET& hSocketRet, int nTimeout, bool* outProxyConnectionFailed = 0);
55 bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout, bool* outProxyConnectionFailed = 0);
57 std::string NetworkErrorString(int err);
59 bool CloseSocket(SOCKET& hSocket);
61 bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking);
65 struct timeval MillisToTimeval(int64_t nTimeout);
66 
67 #endif // BITCOIN_NETBASE_H
CService
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:133
proxyType::IsValid
bool IsValid() const
Definition: netbase.h:34
ConnectSocket
bool ConnectSocket(const CService &addr, SOCKET &hSocketRet, int nTimeout, bool *outProxyConnectionFailed=0)
Definition: netbase.cpp:627
ParseNetwork
enum Network ParseNetwork(std::string net)
Definition: netbase.cpp:51
Lookup
bool Lookup(const char *pszName, CService &addr, int portDefault, bool fAllowLookup)
Definition: netbase.cpp:224
CNetAddr
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
Definition: netaddress.h:30
ConnectSocketByName
bool ConnectSocketByName(CService &addr, SOCKET &hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed=0)
Definition: netbase.cpp:639
MillisToTimeval
struct timeval MillisToTimeval(int64_t nTimeout)
Convert milliseconds to a struct timeval for e.g.
Definition: netbase.cpp:244
SOCKET
u_int SOCKET
Definition: compat.h:44
Network
Network
Definition: netaddress.h:19
IsProxy
bool IsProxy(const CNetAddr &addr)
Definition: netbase.cpp:592
HaveNameProxy
bool HaveNameProxy()
Definition: netbase.cpp:586
SplitHostPort
void SplitHostPort(std::string in, int &portOut, std::string &hostOut)
Definition: netbase.cpp:74
SetSocketNonBlocking
bool SetSocketNonBlocking(SOCKET &hSocket, bool fNonBlocking)
Disable or enable blocking-mode for a socket.
Definition: netbase.cpp:751
proxyType
Definition: netbase.h:28
prcycoin-config.h
LookupSubNet
bool LookupSubNet(const char *pszName, CSubNet &subnet)
Definition: netbase.cpp:667
nConnectTimeout
int nConnectTimeout
Definition: netbase.cpp:45
compat.h
fNameLookup
bool fNameLookup
Definition: netbase.cpp:46
netaddress.h
CNetAddr::IsValid
bool IsValid() const
Definition: netaddress.cpp:188
CSubNet
Definition: netaddress.h:95
proxyType::proxyType
proxyType()
Definition: netbase.h:31
SetNameProxy
bool SetNameProxy(const proxyType &addrProxy)
Definition: netbase.cpp:568
LookupHost
bool LookupHost(const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
Definition: netbase.cpp:184
GetProxy
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
Definition: netbase.cpp:558
proxyType::randomize_credentials
bool randomize_credentials
Definition: netbase.h:37
proxyType::proxyType
proxyType(const CService &proxy, bool randomize_credentials=false)
Definition: netbase.h:32
LookupNumeric
CService LookupNumeric(const char *pszName, int portDefault=0)
Definition: netbase.cpp:234
NetworkErrorString
std::string NetworkErrorString(int err)
Return readable error string for a network error code.
Definition: netbase.cpp:718
serialize.h
CloseSocket
bool CloseSocket(SOCKET &hSocket)
Close socket and set hSocket to INVALID_SOCKET.
Definition: netbase.cpp:735
SetProxy
bool SetProxy(enum Network net, const proxyType &addrProxy)
Definition: netbase.cpp:548
GetNetworkName
std::string GetNetworkName(enum Network net)
Definition: netbase.cpp:60
proxyType::proxy
CService proxy
Definition: netbase.h:36