-rw-r--r-- | Resolver.cpp | 71 |
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 | ||
12 | static char THIS_FILE[] = __FILE__; | ||
13 | #endif | ||
14 | |||
15 | ///////////////////////////////////////////////////////////////////////////// | ||
16 | // CResolver | ||
17 | |||
18 | CResolver::CResolver() | ||
19 | { | ||
20 | ASSERT(NULL); | ||
21 | } | ||
22 | |||
23 | CResolver::~CResolver() | ||
24 | { | ||
25 | } | ||
26 | |||
27 | |||
28 | BEGIN_MESSAGE_MAP(CResolver, CWnd) | ||
29 | //{{AFX_MSG_MAP(CResolver) | ||
30 | ON_WM_CREATE() | ||
31 | ON_MESSAGE(WM_RESOLVED, OnResolved) | ||
32 | //}}AFX_MSG_MAP | ||
33 | END_MESSAGE_MAP() | ||
34 | |||
35 | |||
36 | ///////////////////////////////////////////////////////////////////////////// | ||
37 | // CResolver message handlers | ||
38 | |||
39 | CResolver::CResolver(CXferSocket *socket) | ||
40 | : socket(socket) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | int CResolver::OnCreate(LPCREATESTRUCT lpCreateStruct) | ||
45 | { | ||
46 | if (CWnd::OnCreate(lpCreateStruct) == -1) | ||
47 | return -1; | ||
48 | |||
49 | ASSERT(socket); | ||
50 | CString hostName = socket->m_HostName; | ||
51 | int 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 | |||
59 | LRESULT CResolver::OnResolved(WPARAM wP,LPARAM lP) | ||
60 | { | ||
61 | if(WSAGETASYNCERROR(lP)) | ||
62 | socket->OnFailedToResolve(); | ||
63 | else | ||
64 | socket->OnResolved(); | ||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | BOOL CResolver::Resolve() | ||
69 | { | ||
70 | return Create(NULL,"PumpKIN-Resolver",WS_CHILD,CRect(0,0,0,0),socket->m_Daddy,0); | ||
71 | } | ||