WSAStringToAddress (Windows Embedded CE 6.0)
1/6/2010
This function converts a numeric string to a sockaddr structure suitable for passing to Windows Sockets routines that take such a structure.
Syntax
INT WSAStringToAddress(
LPTSTR AddressString,
INT AddressFamily,
LPWSAPROTOCOL_INFO lpProtocolInfo,
LPSOCKADDR lpAddress,
LPINT lpAddressLength
);
Parameters
- AddressString
[in] Pointer to the null-terminated human-readable numeric string to convert.
- AddressFamily
[in] Address family to which the string belongs.
- lpProtocolInfo
[in] (optional) WSAPROTOCOL_INFO structure associated with the provider to be used. If this is NULL, the call is routed to the provider of the first protocol supporting the indicated AddressFamily.
- lpAddress
[out] Buffer that is filled with a single sockaddr.
- lpAddressLength
[in, out] Length of the Address buffer. Returns the size of the resultant sockaddr structure. 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 size in bytes.
Return Value
If no error occurs, this function returns zero. If an error occurs, the value SOCKET_ERROR is returned, and a specific error number can be retrieved by calling WSAGetLastError.
The following table shows a list of possible error codes.
Error code | Description |
---|---|
WSAEFAULT |
The specified Address buffer is too small. Pass in a larger buffer. |
WSAEINVAL |
Unable to translate the string into a sockaddr. |
WSANOTINITIALIZED |
ws2.dll has not been initialized. The application must first call WSAStartup before calling any Windows Sockets functions. |
WSA NOT ENOUGH MEMORY |
There was insufficient memory to perform the operation. |
Remarks
This function converts alphanumeric addresses to sockaddr structures. This function is the protocol-independent equivalent of the BSD inet_addr function.
Any missing parts 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.
This function fails (and returns WSAEINVAL) if the sin_family member of the sockaddr_in structure, which is passed in the lpAddress parameter in the form of a sockaddr structure, is not set to AF_INET.
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