ClientApi::DefinePort( const char *, Error * )

Sets P4PORT in the Windows registry and applies the setting immediately.

Virtual?

No

 

Class

ClientApi

 

Arguments

const char *c

the new P4PORT setting

 

Error *e

an Error object

Returns

void

 

Notes

In order to make the new P4PORT setting apply to the next client connection opened with Init(), DefinePort() sets the value in the registry and then calls SetPort().

Example

The following code illustrates how this method might be used to make a Windows client application automatically set itself to access a backup server if the primary server fails to respond. (This example assumes the existence of a backup server that perfectly mirrors the primary server.)

client.Init( &e );

if ( e.IsFatal() )
{
    e.Clear();
    ui.OutputError( "No response from server - switching to backup!\n" );
    client.DefinePort( "backup:1666", &e );
    client.Init( &e );
}

The first command to which the primary server fails to respond results in the error message and the program reinitializing the client to point to the server at backup:1666. Subsequent commands do not display the warning because the new P4PORT value has been set in the registry.