Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

AsyncResolverQuery.h

Go to the documentation of this file.
00001 /*  AsyncResolverQuery.h - asynchronous DNS query encapsulation
00002     Copyright (C) 2004 Mark Weaver
00003     Written by Mark Weaver <mark@npsl.co.uk>
00004 
00005     Part of the Open-Win32 library.
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the
00018     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA  02111-1307, USA.
00020 */
00021 
00022 /* Copyright 1998 by the Massachusetts Institute of Technology.
00023  *
00024  * Permission to use, copy, modify, and distribute this
00025  * software and its documentation for any purpose and without
00026  * fee is hereby granted, provided that the above copyright
00027  * notice appear in all copies and that both that copyright
00028  * notice and this permission notice appear in supporting
00029  * documentation, and that the name of M.I.T. not be used in
00030  * advertising or publicity pertaining to distribution of the
00031  * software without specific, written prior permission.
00032  * M.I.T. makes no representations about the suitability of
00033  * this software for any purpose.  It is provided "as is"
00034  * without express or implied warranty.
00035  */
00036 
00041 #ifndef OW32_AsyncResolverQuery_h
00042 #define OW32_AsyncResolverQuery_h
00043 
00044 #include <OW32/IoCompletion.h>
00045 #include <OW32/IoCompletionThreadPool.h>
00046 #include <OW32/auto_buf.h>
00047 #include <OW32/AsyncSocket.h>
00048 
00049 #include <vector>
00050 
00051 #include <OW32/AsyncResolverError.h>
00052 
00053 namespace OW32
00054 {
00055 
00056 class OW32_LIB_EXPORT CAsyncResolver;
00057 
00058 #ifdef _MSC_VER
00059 #pragma warning(disable: 4251)
00060 #endif
00061 
00066 class OW32_LIB_EXPORT CAsyncResolverQueryCallback
00067 {
00068 public: 
00076     virtual void OnAnswer(AsyncResolverError status, unsigned char *abuf, size_t alen) = 0;
00077 };
00078 
00082 class OW32_LIB_EXPORT CAsyncResolverCallback
00083 {
00084 public: 
00093     virtual void OnAnswer(void *context, AsyncResolverError status, unsigned char *abuf, size_t alen) = 0;
00094 };
00095 
00097 class OW32_LIB_EXPORT CAsyncResolverQuery : 
00098     public CAsyncResolverQueryCallback,
00099     public CRefCounted
00100 {
00101 public:
00109     CAsyncResolverQuery(CAsyncResolver *pParent, CAsyncResolverCallback *pCallback, void *callbackContext = 0);
00110 
00112     virtual void OnAnswer(AsyncResolverError status, unsigned char *abuf, size_t alen);
00113 
00115     void query(const char *name, int dnsclass, int type);
00116 
00118     const auto_byte_buf &getQuery() const { return m_query; }
00119 
00121     int getId() const { return m_id; }
00122 
00124     const bool getUsingTCP() const { return m_using_tcp; }
00125 
00130     void setUsingTCP(bool using_tcp) { m_using_tcp = using_tcp; }
00131 
00132 private:
00134     CAsyncResolverQuery(const CAsyncResolverQuery &);
00135     CAsyncResolverQuery& operator=(const CAsyncResolverQuery &);
00136 
00138     AsyncResolverError mkquery(const char *name, int dnsclass, int type, 
00139                 unsigned short id, int rd);
00140 
00141 protected:
00143     CAsyncResolver              *m_pParent;
00145     auto_byte_buf               m_query;
00147     int                         m_try;
00149     size_t                      m_server;
00151     int                         m_id;
00153     bool                        m_using_tcp;
00155     std::vector<bool>           m_skip_server;
00157     AsyncResolverError          m_error_status;
00159     CAsyncResolverCallback      *m_pCallback;
00161     void                        *m_callbackContext;
00162 
00167     friend class CAsyncResolver;
00168 };
00169 
00170 #ifdef _MSC_VER
00171 #pragma warning(default: 4251)
00172 #endif
00173 
00175 typedef CAutoRefCountedPtr<CAsyncResolverQuery> CAsyncResolverQueryPtr;
00176 
00177 } // namespace OW32
00178 
00179 #endif // OW32_AsyncResolverQuery_h

Generated on Sun Jun 5 01:29:17 2005 for OW32 by  doxygen 1.3.9.1