We should include netinet/in.h to use sockaddr_in (POSIX.1-2001)
[novacoin.git] / src / netbase.h
index 6f06f8f..26c2140 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Bitcoin developers
+// Copyright (c) 2009-2012 The Bitcoin developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
 #ifndef BITCOIN_NETBASE_H
@@ -19,8 +19,6 @@
 #include <netdb.h>
 #include <net/if.h>
 #include <ifaddrs.h>
-#endif
-#ifdef BSD
 #include <netinet/in.h>
 #endif
 
@@ -30,7 +28,7 @@
 extern int nConnectTimeout;
 
 
-// IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
+/** IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96)) */
 class CNetAddr
 {
     protected:
@@ -39,8 +37,8 @@ class CNetAddr
     public:
         CNetAddr();
         CNetAddr(const struct in_addr& ipv4Addr);
-        CNetAddr(const char *pszIp, bool fAllowLookup = false);
-        CNetAddr(const std::string &strIp, bool fAllowLookup = false);
+        explicit CNetAddr(const char *pszIp, bool fAllowLookup = false);
+        explicit CNetAddr(const std::string &strIp, bool fAllowLookup = false);
         void Init();
         void SetIP(const CNetAddr& ip);
         bool IsIPv4() const;    // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
@@ -81,6 +79,7 @@ class CNetAddr
             )
 };
 
+/** A combnation of a network address (CNetAddr) and a (TCP) port */
 class CService : public CNetAddr
 {
     protected:
@@ -91,10 +90,10 @@ class CService : public CNetAddr
         CService(const CNetAddr& ip, unsigned short port);
         CService(const struct in_addr& ipv4Addr, unsigned short port);
         CService(const struct sockaddr_in& addr);
-        CService(const char *pszIp, int port, bool fAllowLookup = false);
-        CService(const char *pszIpPort, bool fAllowLookup = false);
-        CService(const std::string& strIp, int port, bool fAllowLookup = false);
-        CService(const std::string& strIpPort, bool fAllowLookup = false);
+        explicit CService(const char *pszIpPort, int portDefault, bool fAllowLookup = false);
+        explicit CService(const char *pszIpPort, bool fAllowLookup = false);
+        explicit CService(const std::string& strIpPort, int portDefault, bool fAllowLookup = false);
+        explicit CService(const std::string& strIpPort, bool fAllowLookup = false);
         void Init();
         void SetPort(unsigned short portIn);
         unsigned short GetPort() const;
@@ -125,9 +124,10 @@ class CService : public CNetAddr
             )
 };
 
-bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions = 0, bool fAllowLookup = true);
-bool LookupHostNumeric(const char *pszName, std::vector<CNetAddr>& vIP, int nMaxSolutions = 0);
+bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true);
+bool LookupHostNumeric(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0);
 bool Lookup(const char *pszName, CService& addr, int portDefault = 0, bool fAllowLookup = true);
+bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault = 0, bool fAllowLookup = true, unsigned int nMaxSolutions = 0);
 bool LookupNumeric(const char *pszName, CService& addr, int portDefault = 0);
 bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout = nConnectTimeout);