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

C/C++ API Documentation | 2025.1

# ClientApi::GetPort()

Get current port setting.

Virtual? | No |
Class | `ClientApi` |
Arguments | None |
Returns | `const StrPtr &` | a reference to the port setting

## Notes

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

If the environment variable `P4PORT` is unset, `GetPort()` sets the port to the default value of `perforce:1666`.

## Example

The following example demonstrates the usage of `GetPort()`.

    ClientApi client;

    printf( "You're looking for a server at %s\n", \
             client.GetPort().Text() );

Executing the preceding code produces the following output:

    You're looking for a server at perforce:1666

Your search for returned results