home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Contrib / NSISdl / asyncdns.h < prev    next >
C/C++ Source or Header  |  2002-08-02  |  1KB  |  39 lines

  1. /*
  2. ** JNetLib
  3. ** Copyright (C) 2000-2001 Nullsoft, Inc.
  4. ** Author: Justin Frankel
  5. ** File: asyncdns.h - JNL portable asynchronous DNS interface
  6. ** License: see jnetlib.h
  7. **
  8. ** Usage:
  9. **   1. Create JNL_AsyncDNS object, optionally with the number of cache entries.
  10. **   2. call resolve() to resolve a hostname into an address. The return value of 
  11. **      resolve is 0 on success (host successfully resolved), 1 on wait (meaning
  12. **      try calling resolve() with the same hostname in a few hundred milliseconds 
  13. **      or so), or -1 on error (i.e. the host can't resolve).
  14. **   4. enjoy.
  15. */
  16.  
  17. #ifndef _ASYNCDNS_H_
  18. #define _ASYNCDNS_H_
  19.  
  20. class JNL_AsyncDNS
  21. {
  22. public:
  23.   JNL_AsyncDNS(int max_cache_entries=64);
  24.   ~JNL_AsyncDNS();
  25.  
  26.   int resolve(char *hostname, unsigned long *addr); // return 0 on success, 1 on wait, -1 on unresolvable
  27.  
  28. private:
  29.   char m_hostname[256];
  30.   unsigned long m_addr;
  31.  
  32.   volatile int m_thread_kill;
  33.   HANDLE m_thread;
  34.   static unsigned long WINAPI _threadfunc(LPVOID _d);
  35.  
  36. };
  37.  
  38. #endif //_ASYNCDNS_H_
  39.