summaryrefslogtreecommitdiffabout
path: root/Resolver.cpp
Unidiff
Diffstat (limited to 'Resolver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--Resolver.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/Resolver.cpp b/Resolver.cpp
new file mode 100644
index 0000000..0ec66d3
--- a/dev/null
+++ b/Resolver.cpp
@@ -0,0 +1,71 @@
1// Resolver.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "Resolver.h"
7#include "PumpKINDlg.h"
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15/////////////////////////////////////////////////////////////////////////////
16// CResolver
17
18CResolver::CResolver()
19{
20 ASSERT(NULL);
21}
22
23CResolver::~CResolver()
24{
25}
26
27
28BEGIN_MESSAGE_MAP(CResolver, CWnd)
29 //{{AFX_MSG_MAP(CResolver)
30 ON_WM_CREATE()
31 ON_MESSAGE(WM_RESOLVED, OnResolved)
32 //}}AFX_MSG_MAP
33END_MESSAGE_MAP()
34
35
36/////////////////////////////////////////////////////////////////////////////
37// CResolver message handlers
38
39CResolver::CResolver(CXferSocket *socket)
40 : socket(socket)
41{
42}
43
44int CResolver::OnCreate(LPCREATESTRUCT lpCreateStruct)
45{
46 if (CWnd::OnCreate(lpCreateStruct) == -1)
47 return -1;
48
49 ASSERT(socket);
50CString hostName = socket->m_HostName;
51int at = hostName.Find('@');
52 if(at>=0)
53 hostName=hostName.Mid(at+1);
54 m_hAsync=WSAAsyncGetHostByName(m_hWnd,WM_RESOLVED,(LPCTSTR)hostName,(char*)socket->m_ResolveBuff,sizeof(socket->m_ResolveBuff));
55 ASSERT(m_hAsync);
56 return 0;
57}
58
59LRESULT CResolver::OnResolved(WPARAM wP,LPARAM lP)
60{
61 if(WSAGETASYNCERROR(lP))
62 socket->OnFailedToResolve();
63 else
64 socket->OnResolved();
65 return 0;
66}
67
68BOOL CResolver::Resolve()
69{
70 return Create(NULL,"PumpKIN-Resolver",WS_CHILD,CRect(0,0,0,0),socket->m_Daddy,0);
71}