tfGetHostByName
Table of Contents >> Application Reference >> DNS Resolver
| #include <trsocket.h> |
| int tfGetHostByName | ( |
| const char TM_FAR * hostnameStr, | |
| struct tsHostent TM_FAR * TM_FAR * hostEntryPtrPtr | |
| ); |
Function Description
Retrieve all host addresses for the specified hostname. This function is similar to Treck functions getaddrinfo() and tfDnsGetHostByName() except this function will first search the Hosts Table for a matching hostname. If there is no entry in the Hosts Table for hostnameStr, this function will generate a DNS query in an attempt to resolve the name externally. The information returned by this function is snapshot of potentially transient data. The volatile data is copied into a dynamically allocated block of memory, to which a pointer is returned. The caller must eventually free the block by calling tfFreeHostEntry() with the pointer returned by this function.
Parameters
- hostnameStr
- Name of the host to resolve to an IP address.
- hostEntryPtrPtr
- Pointer to a variable to receive a pointer to the data.
| The caller must eventually call tfFreeHostEntry() with the pointer returned by this function when the host information is no longer needed. |
Returns
- TM_ENOERROR
- Success.
- TM_EPERM
- Call tfDnsInit() first.
- TM_EINVAL
- A NULL pointer was provided.
- TM_ENOMEM
- Memory allocation failed.
- TM_EAFNOSUPPORT
- addressPtr or addressFamily is not AF_INET or AF_INET6.
- TM_EWOULDBLOCK
- DNS lookup in progress. The user should continue to call this function with the same parameters until it returns a value other than TM_EWOULDBLOCK.
- TM_ENOBUFS
- Insufficient packet buffers.
- TM_EFILE
- Treck was unable to successfully allocate a socket for the DNS request. This could indicate Treck did not have the resources to allocate another socket. It could also be due to Treck hitting the limit of sockets set by TM_DNS_MAX_SOCKETS_ALLOWED or the tfDnsSetOption() option: TM_DNS_OPTION_MAX_SOCKETS_ALLOWED.
- TM_ETIMEDOUT
- DNS server failed to respond in a timely fashion.
- TM_EHOSTUNREACH
- No route to DNS server.
- TM_DNS_EANSWER
- No answer from the name server.
- TM_DNS_ECACHE_FULL
- Response lost, internal DNS cache is full.
- TM_EINPROGRESS
- Cannot replace a cache entry that is currently being used.