Using Host Descriptions

Host descriptions are required by Connect.

This section describes how to create a host description in order to connect to a server.

Host descriptions have the following formats:

"<host-type><IP address><port><protocol>"
"<host-type><IP address><port> udp <RTO><Rc><Rm>"
"<host-type><IP address><port> tcp <Ti>"

The different parts of a host description can be set using the AnyFirewallâ„¢ Engine API functions CreateHost, SetHostType, SetHostAddress, SetHostPort, SetHostProtocol. Similar functions are available to retrieve the information. For more details, please refer to section 7. C++ Function Reference.

Host descriptions are required when using Connect to connect to a server with a public IP address, e.g. a SIP proxy. In this case, CreateHost is used to create a host description of the server (see section 7. C++ Function Reference). The host description list contains only a single host description of type public (AF_HOST_PUBLIC) and the IP address, port and transport protocol of the server. It is also possible to use DNS SRV lookups to identify a suitable server to connect. In this case, the host type AF_HOST_DNS_SRV is used instead of AF_HOST_PUBLIC.

string sTarget = "_stun._udp." + sDomain;
string sDnsSrv = m_pAFEngine->CreateHost(AF_HOST_DNS_SRV,
m_pAFEngine->SetSTUNServer(serverStoreID, sDnsSrv);

In this case, the host description is passed to API functions defining a server to use, such as SetSTUNServer. Host descriptions can be concatenated (separated with a semicolon), which is required in case a server supports several transport protocols. For example, in order to enable TCP and UDP relaying, two host descriptions are concatenated to describe the UDP and TCP interfaces of a TURN server.