Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2025.1

# ClientApi::SetHost( const StrPtr * )

Sets the hostname to be used for this connection.

Virtual? | No | Class
`ClientApi` |  | Arguments
`const StrPtr *c` | the new hostname value | Returns

## Notes

`SetHost()` does not permanently change the host name of the client or set `P4HOST` in the environment. The new setting applies only to commands executed by calling this `ClientApi` object’s `Run()` method.

## Example

The following example sets different hostnames and displays them with `p4 info`.

    ClientApi client;
    ClientUser ui;
    StrBuf sb1;
    StrBuf sb2;

    sb1 = "magic";
    sb2 = "shire";

    client.SetHost( &sb1 );
    client.Run( "info", &ui );

    client.SetHost( &sb2 );
    client.Run( "info", &ui );

Your search for returned results