Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

pos_cliresolver Class Reference

resolver for client applications More...

Inheritance diagram for pos_cliresolver:

pos_resolver List of all members.

Public Member Functions

  pos_cliresolver ()
  resolver constructor

virtual  ~pos_cliresolver ()
  destructor

void  query (DnsMessage *q, DnsMessage *&a, _addr *server, int flags=Q_DFL)
  high-level query function

void  query (DnsMessage *q, DnsMessage *&a, stl_slist(_addr)&servers, int flags=Q_DFL)
  high-level query function using multiple servers

void  sendmessage (DnsMessage *msg, _addr *res, int sockid=-1)
  low-level resolver function for sending a message

bool  waitanswer (DnsMessage *&ans, stl_slist(WaitAnswerData)&wait, int timeout, stl_slist(WaitAnswerData)::iterator &it, int sockid=-1)
  low-level resolver function for waiting for an answer

void  stop ()
  stops the resolving process asap


Detailed Description

resolver for client applications

This is an implementation of the pos_resolver class meant for client applications. It does not maintain a centralized query database like pos_srvresolver. Instead, it will open up a new socket for each query it attempts. The advantage is that it does not require the multi-thread architecture pos_srvresolver depends on.

pos_cliresolver implements the pos_resolver query(), sendmessage() and waitanswer() functions.

Definition at line 270 of file resolver.h.


Constructor & Destructor Documentation

pos_cliresolver::pos_cliresolver  ) 
 

resolver constructor

Resolver for the client resolver.

virtual pos_cliresolver::~pos_cliresolver  )  [virtual]
 

destructor

Destructor for the client resolver


Member Function Documentation

void pos_cliresolver::query DnsMessage q,
DnsMessage *&  a,
stl_slist(_addr)&  servers,
int  flags = Q_DFL
[virtual]
 

high-level query function using multiple servers

This function generally behaves the same as the query() function, except it takes a list of servers instead of one. The query algorithm differs in that for each timeout value from udp_tries, all servers will be queried. Also, if the answer is truncated, _only_ the server that returned the truncated answer will be tried using TCP. This function will start querying at a random place in the servers list; after that, it will run through all servers listed in the order in which you specify them.

Parameters:
servers  List of servers to query
See also:
query()

Reimplemented from pos_resolver.

void pos_cliresolver::query DnsMessage q,
DnsMessage *&  a,
_addr server,
int  flags = Q_DFL
[virtual]
 

high-level query function

This function will query the given DNS server for the information identified by the DNS query message q. If it succeeds, it will return and put the answer from the server in a, which need not be initialized previously (in fact, this will result in a memory leak). If not, it will raise a PException.

If the query() function does not receive an answer in time, it will retry for n_udp_tries times, using the timeout values from the udp_tries array. If the answer it receives is truncated, it will retry using TCP, unless instructed not to by the flags parameter.

The behavior of the query function can be changed by the flags parameter. Currently, this can only be Q_DFL (default flags) or Q_NOTCP (do not retry using UDP).

Parameters:
q  The DNS query message
a  Variable to put the answer in
server  The server to query
flags  Flags controlling query behavior.

Reimplemented from pos_resolver.

void pos_cliresolver::sendmessage DnsMessage msg,
_addr res,
int  sockid = -1
[virtual]
 

low-level resolver function for sending a message

This function sends a DNS message to a specified server using UDP.

Parameters:
msg  The DNS message to send
res  The host to send the message to
sockid  The socket to use

Reimplemented from pos_resolver.

void pos_cliresolver::stop  ) 
 

stops the resolving process asap

This function will try to stop the resolving process as soon as possible. Thus, it will need to be called asynchronously (since the query functions block), either from another thread or from a signal handler. It will tease the query functions a bit by closing their sockets, and urge them to quit.

bool pos_cliresolver::waitanswer DnsMessage *&  ans,
stl_slist(WaitAnswerData)&  wait,
int  timeout,
stl_slist(WaitAnswerData)::iterator &  it,
int  sockid = -1
[virtual]
 

low-level resolver function for waiting for an answer

This function waits for at most the amount of milliseconds specified by timeout until an answer to our query arrives. Since multiple messages for the same query might have been sent out, it asks for a list of sent queries.

If no answer is received in time, this function will raise an exception.

Parameters:
ans  If an answer is received, it will be put in this variable
wait  List of sent queries we might get an answer to
timeout  Number of milliseconds to wait at most
it  If an answer is received, this iterator will point to the message this was an answer to.
sockid  The socket id the answers will come from.

Reimplemented from pos_resolver.


The documentation for this class was generated from the following file:
Generated on Fri Dec 24 19:55:16 2004 for Poslib by doxygen 1.3.7