Share via


WSAAddressToString (Windows Embedded CE 6.0)

1/6/2010

This function converts all parts of a sockaddr structure into a human-readable string representation of the address.

This function is intended to be used for display purposes. If the caller wants the translation to be done by a particular provider, it should supply the corresponding WSAPROTOCOL_INFO structure in the lpProtocolInfo parameter.

Syntax

INT WSAAddressToString(
  LPSOCKADDR lpsaAddress,
  DWORD dwAddressLength,
  LPWSAPROTOCOL_INFO lpProtocolInfo,
  OUT LPTSTR lpszAddressString,
  IN OUT LPDWORD lpdwAddressStringLength
);

Parameters

  • lpsaAddress
    [in] Pointer to the sockaddr structure to translate into a string.

    Note

    A sockaddr pointer needs to be aligned on a 4 byte boundary (DWORD aligned).

  • dwAddressLength
    [in] Length of the address in sockaddr, which may vary in size with different protocols.
  • lpProtocolInfo
    [in] (Optional) The WSAPROTOCOL_INFO structure for a particular provider. If this is NULL, the call is routed to the provider of the first protocol supporting the address family indicated in lpsaAddress.
  • lpszAddressString
    [in] Buffer that receives the human-readable address string.
  • lpdwAddressStringLength
    [in, out] On input, the length of the AddressString buffer in characters. On output, returns the length of the string actually copied into the buffer including the terminating NULL character. If the supplied buffer is not large enough, the function fails with a specific error of WSAEFAULT and this parameter is updated with the required string length in characters.

Return Value

If no error occurs, this function returns a value of zero. If an error occurs, the value SOCKET_ERROR is returned, and a specific error number can be retrieved by calling the WSAGetLastError function. The following table shows a list of possible error codes.

Error code Description

WSAEFAULT

The specified lpcsAddress, lpProtocolInfo, and lpszAddressString are not all in the address space of the process, or the lpszAddressString buffer is too small. Pass in a larger buffer.

WSAEINVAL

The specified address is not a valid socket address, or there was no transport provider supporting its indicated address family.

WSANOTINITIALIZED

The Ws2.dll has not been initialized. The application must first call WSAStartup before calling any Winsock functions.

WSA_NOT_ENOUGH_MEMORY

There was insufficient memory to perform the operation.

Requirements

Header winsock2.h
Library Ws2.lib
Windows Embedded CE Windows CE .NET 4.0 and later

See Also

Reference

sockaddr
WSAGetLastError
WSAStartup

Concepts

Windows-Specific Extension Functions