Dbmlsync API for C++

This section describes the methods in the C++ implementation of the DbmlsyncClient class.

The sample below shows a typical application using the C++ version of the Dbmlsync API to perform a synchronization to receive output events. The sample omits error handling for clarity. It is always good indent practice to check the return value from each API call.

Dbmlsync C++ sample
#include <stdio.h>
#include "dbmlsynccli.h"


int main( void ) {
    DbmlsyncClient *client;
    DBSC_SyncHdl    syncHdl;
    DBSC_Event     *ev1;

    client = DbmlsyncClient::InstantiateClient();
    if( client == NULL ) return( 1 );
    client->Init();

    // Setting the "server path" is usually required on Windows Mobile/CE.
    // In other environments the server path is usually not required unless
    // you SA install is not in your path or you have multiple versions of the
    // product installed
    client->SetProperty( "server path", "C:\\SQLAnywhere\\bin32" );

    client->StartServer( 3426,
              "-c eng=remote;dbn=rem1;uid=dba;pwd=sql -v+ -ot c:\\dbsync1.txt",
              5000, NULL );
    client->Connect( NULL, 3426, "dba", "sql");
    syncHdl = client->Sync( "my_sync_profile", "" );
    while( client->GetEvent( &ev1, 5000) == DBSC_GETEVENT_OK ) {
        if( ev1->hdl == syncHdl ) {
            //
            // Process events that interest you here
            //

            if( ev1->type == DBSC_EVENTTYPE_SYNC_DONE ) {
                client->FreeEventInfo( ev1 );
                break;
            }
            client->FreeEventInfo( ev1 );
         }
     }
     client->ShutdownServer( DBSC_SHUTDOWN_ON_EMPTY_QUEUE );
     client->WaitForServerShutdown( 10000 );
     client->Disconnect();
     client->Fini();
     delete client;

     return( 0 );
}

The DbmlsyncClient class public methods in the C++ version of the API are shown below.


InstantiateClient method
Init method
Fini method
StartServer method
Connect method
Disconnect method
Ping method
Sync method
ShutdownServer method
WaitForServerShutdown method
CancelSync method
GetEvent method
FreeEventInfo method
GetErrorInfo method
SetProperty method
GetProperty method
DBSC_Event structure