The Windows Sockets WSAStringToAddress function converts a numeric string to a SOCKADDR structure, suitable for passing to Windows Sockets routines that take such a structure.
INT WSAStringToAddress(
LPTSTR AddressString,
INT AddressFamily,
LPWSAPROTOCOL_INFO lpProtocolInfo,
LPSOCKADDR lpAddress,
LPINT lpAddressLength
);
The WSAStringToAddress function converts alpha-numeric address to SOCKADDR structures. WSAStringToAddress is the protocol independent equivalent of the BSD inet_ntoa function.
Any missing components of the address will be defaulted to a reasonable value, if possible. For example, a missing port number will default to zero. 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.
The return value for WSAStringToAddress is zero if the operation was successful. Otherwise, the value SOCKET_ERROR is returned, and a specific error number can be retrieved by calling WSAGetLastError.
WSAEFAULT | The specified Address buffer is too small. Pass in a larger buffer. |
WSAEINVAL | Unable to translate the string into a SOCKADDR. |
WSANOTINITIALIZED | The WS2_32.DLL has not been initialized. The application must first call WSAStartup before calling any Windows Socket functions. |
WSA NOT ENOUGH MEMORY | There was insufficient memory to perform the operation. |
Windows NT: Yes
Windows: Yes
Windows CE: Unsupported.
Header: Declared in winsock2.h.
Import Library: Link with ws2_32.lib.