aboutsummaryrefslogtreecommitdiff
path: root/dep/src/sockets/ResolvSocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dep/src/sockets/ResolvSocket.cpp')
-rw-r--r--dep/src/sockets/ResolvSocket.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/dep/src/sockets/ResolvSocket.cpp b/dep/src/sockets/ResolvSocket.cpp
index f97be03cd06..236e93f9704 100644
--- a/dep/src/sockets/ResolvSocket.cpp
+++ b/dep/src/sockets/ResolvSocket.cpp
@@ -4,20 +4,25 @@
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
+
This library is made available under the terms of the GNU GPL.
+
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -37,20 +42,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ISocketHandler.h"
#include "Lock.h"
#include "Mutex.h"
+
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
+
//#ifdef _DEBUG
//#define DEB(x) x
//#else
#define DEB(x)
//#endif
+
// static
ResolvSocket::cache_t ResolvSocket::m_cache;
ResolvSocket::timeout_t ResolvSocket::m_cache_to;
Mutex ResolvSocket::m_cache_mutex;
+
ResolvSocket::ResolvSocket(ISocketHandler& h)
:TcpSocket(h)
,m_bServer(false)
@@ -63,6 +72,7 @@ ResolvSocket::ResolvSocket(ISocketHandler& h)
SetLineProtocol();
}
+
ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, const std::string& host, port_t port, bool ipv6)
:TcpSocket(h)
,m_bServer(false)
@@ -77,6 +87,7 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, const std::string&
SetLineProtocol();
}
+
ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, ipaddr_t a)
:TcpSocket(h)
,m_bServer(false)
@@ -91,6 +102,7 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, ipaddr_t a)
SetLineProtocol();
}
+
#ifdef ENABLE_IPV6
ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, in6_addr& a)
:TcpSocket(h)
@@ -105,10 +117,12 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, in6_addr& a)
}
#endif
+
ResolvSocket::~ResolvSocket()
{
}
+
void ResolvSocket::OnLine(const std::string& line)
{
Parse pa(line, ":");
@@ -170,6 +184,7 @@ DEB(fprintf(stderr, " *** Returning cache for [%s][%s] = '%s'\n", m_query.c_str(
std::string key = pa.getword();
std::string value = pa.getrest();
DEB( fprintf(stderr, " *** ResolvSocket response; %s: %s\n", key.c_str(), value.c_str());)
+
if (key == "Cached")
{
m_cached = true;
@@ -253,6 +268,7 @@ DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(),
#endif
}
+
void ResolvSocket::OnDetached()
{
DEB( fprintf(stderr, " *** ResolvSocket::OnDetached(); query=%s, data=%s\n", m_query.c_str(), m_data.c_str());)
@@ -354,6 +370,7 @@ DEB( fprintf(stderr, " *** ResolvSocket::OnDetached(); query=%s, data=%s\n",
SetCloseAndDelete();
}
+
void ResolvSocket::OnConnect()
{
if (!m_resolv_host.empty())
@@ -388,6 +405,7 @@ void ResolvSocket::OnConnect()
Send( msg );
}
+
void ResolvSocket::OnDelete()
{
if (m_parent)
@@ -409,8 +427,11 @@ DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(),
}
}
+
#ifdef SOCKETS_NAMESPACE
}
#endif
+
#endif // ENABLE_RESOLVER
+