Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cNetHostAsync.h
Go to the documentation of this file.
1 //
6 //
7 
8 #ifndef _INC_cNetHostAsync_H
9 #define _INC_cNetHostAsync_H
10 #ifndef NO_PRAGMA_ONCE
11 #pragma once
12 #endif
13 
14 #include "cNetSystem.h"
15 
16 #if defined(_WIN32) && ! defined(UNDER_CE)
17 #include "../WinAPI/WinTypes.h"
18 #include "GrayCore/include/cHeap.h"
20 
21 namespace GrayLib
22 {
23  class cNetAddress;
24 
25  class GRAYLIB_LINK cNetHostAsync
26  {
31 
32  protected:
33  HANDLE m_hHostReq;
34  private:
35  cHeapBlock m_HostData;
36  protected:
37  hostent* GetAsyncSetup();
38  public:
39  cNetHostAsync()
40  : m_hHostReq(HANDLE_NULL)
41  {
42  }
43  ~cNetHostAsync()
44  {
45  AsyncCancel();
46  }
47 
48  HANDLE get_HostReq() const
49  {
50  return m_hHostReq; // The handle to the request.
51  }
52 
53  bool AsyncFindHostEntryByAddr(HWND hWnd, WINMSG_t uMsg, const cNetAddress& addr);
54  bool AsyncFindHostEntryByName(HWND hWnd, WINMSG_t uMsg, const char* pszHostName);
55 
56  // When we get the complete notification message
57  void AsyncComplete();
58  bool AsyncComplete(cNetAddress* pAddr, LSTATUS wError, WORD wLen);
59  void AsyncCancel();
60 
61  const hostent* GetHostEntry() const
62  {
64  return (const hostent*)m_HostData.get_DataBytes();
65  }
66  };
67 };
68 #endif // _WIN32
69 #endif // _INC_cNetHostAsync_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
UINT WINMSG_t
Supplement _WIN32 "windows.h".
Definition: WinTypes.h:111
#define HANDLE_NULL
Invalid OS handle for _WIN32. Not invalid OS handle for linux.
Definition: cOSHandle.h:21
Definition: cMesh.h:22
LONG LSTATUS
AKA error_status_t. FACILITY_WIN32 codes returned from RegCreateKeyEx() etc. Maybe NOT GetLastError()...
Definition: HResult.h:74