ClientApi::GetHost()

Get client hostname.

Virtual?

No

Class

ClientApi

 

Arguments

None

 

Returns

Notes

See GetClient() for more about the StrPtr return value.

In some instances, GetHost() is not valid until after the network connection has been established with Init(). GetHost() attempts to pull its value from earlier SetHost() calls, then from P4HOST in the environment, and then from the value of "hostname" returned by the client OS. If none of these is applicable, a reverse DNS lookup is performed, but the lookup will not work unless the connection has been established with Init().

To guarantee valid results, call GetHost() only after Init() or SetHost(). Because GetHost() might sometimes be called during the execution of GetClient(), this warning applies to both methods.

As noted above, GetHost() does not necessarily return the actual hostname of the machine if it has been overridden by P4HOST or an earlier call to SetHost().

Example

The following example demonstrates the usage of GetHost().

ClientApi client;
client.Init();

printf( "Client hostname is %s\n", client.GetHost().Text() );

Executing the preceding code produces the following output:

shire% a.out
Client hostname is shire