| 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 License.txt |
| 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 |
** Unicode support by Jim Park -- 08/24/2007 |
| 17 |
*/ |
| 18 |
|
| 19 |
// Jim Park: Inet host name is strictly ANSI, no UNICODE for now. |
| 20 |
|
| 21 |
#ifndef _ASYNCDNS_H_ |
| 22 |
#define _ASYNCDNS_H_ |
| 23 |
|
| 24 |
class JNL_AsyncDNS |
| 25 |
{ |
| 26 |
public: |
| 27 |
JNL_AsyncDNS(); |
| 28 |
~JNL_AsyncDNS(); |
| 29 |
|
| 30 |
int resolve(char *hostname, unsigned long *addr); // return 0 on success, 1 on wait, -1 on unresolvable |
| 31 |
|
| 32 |
private: |
| 33 |
void wait_for_thread_death(); |
| 34 |
|
| 35 |
char m_hostname[256]; |
| 36 |
unsigned long m_addr; |
| 37 |
|
| 38 |
HANDLE m_thread; |
| 39 |
static unsigned long WINAPI _threadfunc(LPVOID _d); |
| 40 |
|
| 41 |
}; |
| 42 |
|
| 43 |
#endif //_ASYNCDNS_H_ |