Jump to: navigation, search

Table of Contents >> IPv6 Programmer's Reference

#include <trsocket.h>

int getnameinfo (
const struct sockaddr * addressPtr,
int addressLength,
char * hostname,
int hostnameLength,
char * serviceName,
int serviceNameLength,
int flags

Function Description

Translates an address into it’s corresponding nodename (hostname). Similar to tfDnsGetHostByAddr(). Retrieving a service name or port number is not supported in our implementation of getnameinfo(), so serviceName must be set to NULL.

Non-blocking Mode

Like all of the other DNS functions, getnameinfo can be used in non-blocking mode by specifying TM_BLOCKING_OFF when tfDnsInit() is called. In non-blocking mode, getnameinfo may return TM_EWOULDBLOCK. This indicates that the operation is in progress. Continue to call getnameinfo() until a value other than TM_EWOULDBLOCK is returned, which indicates that the operation is complete. For example code using getnameinfo(), please see the examples/txdns.c file.


  • addressPtr
    Pointer to address to translate.
  • addressLength
    Length of address structure.
  • hostname
    Buffer to copy nodename into on completion.
  • hostnameLength
    Size of hostname buffer.
  • serviceName
    Not used.
  • serviceNameLength
    Not used.
  • flags


    Hostname info retrieved successfully.
    DNS request failed – requests to DNS server timed out.
    No route to DNS server.
    Indicates that an operation is currently in progress and has not yet completed. Only returned in non-blocking mode. (see above)
    NI_NUMERICHOST flag was set, but couldn’t convert binary address into string.
    Unrecognized or unsupported address family.
    Memory allocation failure
    Non-recoverable error occurred.
    No entry found for this address.
    Error from DNS server: Format error. The name server was unable to interpret the query.
    Error from DNS server: Server failure. The name server was unable to process this query due to a problem with the name server.
    Error from DNS server: Name error. Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.
    Error from DNS server: Not implemented. The name server does not support the requested kind of query.
    Error from DNS server: Refused. The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
    No answer received from name server (i.e., response packet received, but it did not contain the answer to our query).
    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.

Table of Contents >> IPv6 Programmer's Reference