getnameinfo

getnameinfo translates a socket address to a node name and service location, all of which are defined in getaddrinfo.

Syntax

Copy
int WSAAPI getnameinfo(
    [in]    const struct sockaddr FAR *sa,
    [in]    socklen_t salen,
    [out]   char FAR *host,
    [in]    DWORD hostlen,
    [out]   char FAR *serv,
    [in]    DWORD servlen,
    [in]    int flags
);

Parameters

[in] sa

A pointer to a socket address structure to be translated.

[in] salen

The size of the socket address structure pointed at by sa.

[out] host

A pointer to a zero-terminated ASCII string containing the hostname.

[in] hostlen

The length of the buffer pointed to by the node parameter, in bytes. The caller must provide a buffer large enough to hold the hostname, including terminating NULL characters. A value of zero indicates the caller does not want to receive the string provided in host.

[out] serv

A pointer to a zero-terminated ASCII string containing the service name associated with the port number.

[in] servlen

Length of the buffer pointed to by the serv parameter, in bytes. The caller must provide a buffer large enough to hold the service name, including terminating null characters. A value of zero indicates the caller does not want to receive the string provided in serv.

[in] flags

The flags argument modifies the behavior of getnameinfo as follows:

Flag Description

NI_NUMERICHOST

If set, the numeric form of the hostname is returned.

NI_NUMERICSERV

If set, the service address is returned in numerical form, e.g., by its port number.

Return Value

If the function succeeds, it returns 0 (zero). If the function fails, it returns a non-zero positive value.

Possible error codes:

Error code Description

WSATRY_AGAIN

The name could not be resolved at this time. Try again later.

WSAEINVAL

ai_flags contains invalid flags.

WSAEAFNOSUPPORT

The requested address family is not supported.

WSA_NOT_ENOUGH_MEMORY

Memory allocation failure.

WSAHOST_NOT_FOUND

The name does not resolve for the supplied parameters.

WSANO_RECOVERY

A non-recoverable error occurred.

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

ws2tcpip.h

RttcpipApi.lib