Dependents: SimpleLCDClock readCard2Twitter_http AnalogClock_StepperMotor_NTP ServoCamV1
Diff: if/net/netdnsrequest.h
- Revision:
- 0:3717b703f76d
- Child:
- 1:e52ec2a24c6a
diff -r 000000000000 -r 3717b703f76d if/net/netdnsrequest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/if/net/netdnsrequest.h Mon May 24 10:23:42 2010 +0000 @@ -0,0 +1,61 @@ +#ifndef NETDNSREQUEST_H +#define NETDNSREQUEST_H + +//class Socket; +class Host; +//class NetService; +class NetDnsRequest; + +#include "netservice.h" +#include "ipaddr.h" +#include "host.h" + +enum NetDnsReply +{ + NETDNS_PRTCL, + NETDNS_NOTFOUND, //Hostname is unknown + NETDNS_ERROR, //Problem with DNS Service + //... + NETDNS_FOUND, +}; + +class NetDnsRequest : public NetService +{ +public: + NetDnsRequest(const char* hostname); + NetDnsRequest(Host* pHost); + virtual ~NetDnsRequest(); + + class CDummy; + template<class T> + //Linker bug : Must be defined here :( + void setOnReply( T* pItem, void (T::*pMethod)(NetDnsReply) ) + { + m_pCbItem = (CDummy*) pItem; + m_pCbMeth = (void (CDummy::*)(NetDnsReply)) pMethod; + } + + //Execute request & return OK if found, NOTFOUND or ERROR on error, or PROCESSING if the request has not completed yet + // virtual DnsErr pollState() = 0; + virtual void poll() = 0; //NetService fn + + void getResult(IpAddr* pIp); + + virtual void close(); + +protected: + void onReply(NetDnsReply reply); //Must be called by impl when the request completes + + IpAddr m_ip; + char* m_hostname; + +private: + CDummy* m_pCbItem; + void (CDummy::*m_pCbMeth)(NetDnsReply); + + Host* m_pHost; + + bool m_closed; +}; + +#endif