C4 Engine
C4 Engine API Documentation

NetworkMgr::ResolveAddress

Defined in:  C4Network.h
Looks up the IP address corresponding to a domain name.
Prototype

DomainNameResolver *ResolveAddress(const char *name);

Parameters
name The domain name of the server whose IP address should be resolved.
Description
Calling the ResolveAddress function causes an object of type DomainNameResolver to be created and maintained by the Network Manager. Domain names are resolved asychronously, so the ResolveAddress function always returns immediately. If the domain name resolution operation is successfully initiated, then the return value is a pointer to a DomainNameResolver object; otherwise, the return value is nullptr.

After a successful call to ResolveAddress, a completion callback should be installed for the returned object. This completion callback is invoked during the next call to NetworkMgr::NetworkTask after the domain name resolution completes. The completion callback can extract the resolved IP address by calling the DomainNameResolver::GetAddress function. After the completion callback is called, the DomainNameResolver object is automatically destroyed.

A domain name resolution can be canceled before its completion callback is invoked by calling the DomainNameResolver::Cancel function.
Special Considerations
The ResolveAddress function should not be called before the Network Manager has been successfully initialized by the NetworkMgr::Initialize function or the MessageMgr::BeginMultiplayerGame function.
See Also

DomainNameResolver