Asynchronous IPv4 resolution API (deprecated)
The resolution APIs described in this document are deprecated and will be removed in a future version. To use the domain name resolution feature, see the latest Domain Name Resolution API documentation.
Asynchronous IPv4 resolution API
This asynchronous resolution API first queries the cache. If a result is found, the API returns it. Otherwise, the API returns a null object and performs an asynchronous domain name resolution to update the cache.
The returned IP address is the first one in the IP array from the server. This IP address may not be optimal.
To ensure that the returned IP address is optimal, use the
Enable IP optimizationAPI.
API definition
- (NSString *)getIpByHostAsync:(NSString *)host;The API name was updated in version 2.1.0. If you use SDK version 2.1.0 or later, use the new API. The old API may be removed in a future version.
- (NSString *)getIPv4ForHostAsync:(NSString *)host;Parameters
Parameter | Type | Required | Description |
host | NSString | Yes | The domain name. For example, www.aliyun.com. |
Get a list of results from asynchronous IPv4 resolution
This asynchronous resolution API retrieves a list of IP addresses. It first queries the cache. If a result list is found, the API returns it. Otherwise, the API returns a null object and performs an asynchronous domain name resolution to update the cache.
API definition
- (NSArray *)getIpsByHostAsync:(NSString *)host;The API name was updated in version 2.1.0. If you use SDK version 2.1.0 or later, use the new API. The old API may be removed in a future version.
- (NSArray *)getIPv4ListForHostAsync:(NSString *)host;Parameters
Parameter | Type | Required | Description |
host | NSString | Yes | The domain name. For example, www.aliyun.com. |
Enable IP optimization
This API sets a list of domain names for IP probing. After you call this API, when a domain name from this list is resolved, the SDK probes the returned IP addresses. The SDK then dynamically sorts the list to ensure that the first IP address has the best availability.
This feature is supported in SDK V1.6.12 and later.
API definition
- (void)setIPRankingDatasource:(NSDictionary<NSString *, NSNumber *> *)IPRankingDatasource;Parameters
Parameter | Type | Required | Description |
IPRankingDatasource | NSDictionary<NSString *, NSNumber *> | Yes | Sets the port number for the corresponding domain name. @{host: port} |
Code example
HttpDnsService *httpdns = [[HttpDnsService alloc] initWithAccountID:XXXX];
NSDictionary *IPRankingDatasource = @{
@"www.abc.com" : @80,
@"www.cba.com" : @443,
@"www.bac.com" : @443
};
[httpdns setIPRankingDatasource:IPRankingDatasource];Get a formatted result for URL scenarios from asynchronous IPv4 resolution
This asynchronous resolution API returns a result that is formatted for URL scenarios. The API first queries the cache. If a result is found, the API returns it. Otherwise, the API returns a null object and performs an asynchronous domain name resolution to update the cache.
API definition
- (NSString *)getIpByHostAsyncInURLFormat:(NSString *)host;Parameters
Parameter | Type | Required | Description |
host | NSString | Yes | The domain name. |