123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef _ASYNCDNS_H_
- #define _ASYNCDNS_H_
- #include "netinc.h"
- struct cache_entry;
- #define JNL_AUTODNS ((JNL_AsyncDNS *)-1)
- enum
- {
- DNS_RESOLVE_UNRESOLVABLE = -1,
- DNS_RESOLVE_SUCCESS = 0,
- DNS_RESOLVE_WAIT = 1,
- };
- enum
- {
- DNS_REVERSE_UNRESOLVABLE = -1,
- DNS_REVERSE_SUCCESS = 0,
- DNS_REVERSE_WAIT = 1,
- };
- class JNL_AsyncDNS
- {
- public:
- JNL_AsyncDNS( int max_cache_entries = 64 );
- ~JNL_AsyncDNS();
- int resolve( const char *hostname, unsigned short port, addrinfo **addr, int sockettype );
- static int resolvenow( const char *hostname, unsigned short port, addrinfo **addr, int sockettype );
-
- private:
- cache_entry *m_cache;
- int m_cache_size;
- volatile int m_thread_kill;
- #ifdef _WIN32
- HANDLE m_thread;
- static unsigned long WINAPI _threadfunc( LPVOID _d );
- #else
- pthread_t m_thread;
- static unsigned int _threadfunc( void *_d );
- #endif
- void makesurethreadisrunning( void );
- };
- #endif
|