The WSPStringToAddress function converts a human-readable numeric string to a socket address structure (SOCKADDR) suitable to passing to Windows Sockets routines which take such a structure.
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.
int WSPStringToAddress (
LPWSTR AddressString,
INT AddressFamily,
LPWSAPROTOCOL_INFOW lpProtocolInfo,
LPSOCKADDR lpAddress,
LPINT lpAddressLength,
LPINT lpErrno
);
A layered service provider supplies an implementation of this function, but it is also a client of this function if and when it calls WSPStringToAddress of the next layer in the protocol chain. Some special considerations apply to this function's lpProtocolInfo parameter as it is propagated down through the layers of the protocol chain.
If the next layer in the protocol chain is another layer then when the next layer's WSPStringToAddress is called, this layer must pass to the next layer a lpProtocolInfo that references the same unmodified WSAPROTOCOL_INFOW structure with the same unmodified chain information. However, if the next layer is the base protocol (that is, the last element in the chain), this layer performs a substitution when calling the base provider's WSPStringToAddress. In this case, the base provider's WSAPROTOCOL_INFOW structure should be referenced by the lpProtocolInfo parameter.
One vital benefit of this policy is that base service providers do not have to be aware of protocol chains.
This same propagation policy applies when propagating a WSAPROTOCOL_INFOW structure through a layered sequence of other functions such as WSPAddressToString, WSPDuplicateSocket, WSPStartup, or WSPSocket.
If no error occurs, WSPStringToAddress returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code is available in lpErrno.
WSAEFAULT | The specified Address buffer is too small. Pass in a larger buffer. |
WSAEINVAL | Unable to translate the string into a SOCKADDR, or the provider was unable to support the indicated address family, or the specified lpProtocolInfo did not refer to a WSAPROTOCOL_INFOW structure supported by the provider. |
Windows NT: Yes
Windows: Yes
Windows CE: Unsupported.
Header: Declared in ws2spi.h.