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

C/C++ API Documentation | 2025.1

# ServerHelperApi::GetClient(Error*)

Creates and initializes a ClientApi object for the specified server

Virtual? | No |
Class | `ServerHelperApi` |
Arguments | `Error *e` | a pointer to an Error object
Returns | `ClientApi* client` | if successful, an initialized ClientApi object; otherwise 0

## Notes

This is a convenience method to get a `ClientApi` object against the server associated with the `ServerHelperApi` object. `GetClient()` is the equivalent of creating a new `ClientApi` object, setting the `P4PORT`, `P4CLIENT`, and `P4USER`, and then running `ClientApi::Init()`. As with `ClientApi::Init()`, protocol variables must be set using `SetProtocol()` before running `GetClient()`.

## See also

`ClientApi::Init()`

## Example

    // Create personal server
    personalServer.CloneFromRemote( 0, 0, debug, &ui, &e )

    // Turn on tagged output for the client
    personalServer.SetProtocolV( P4Tag::v_tag );

    // Get an init'ed ClientApi object
    ClientApi *client = personalServer.GetClient( &e );
    if( !client )
        return 1;

    // Run 'p4 info'
    client->RunTag( "info", &ui );

Your search for returned results