StartServer method

This method first checks to see if there is a dbmlsync server listening on the specified port. If a server is present, the method sets the starttype parameter to DBSC_SS_ALREADY_RUNNING and returns without further action. If no server is found, the method starts a new server using the options specified by the cmdline argument and waits for it to start accepting requests before returning.

Note

In Windows Mobile devices, it is usually necessary to set the server path property before StartServer can be successfully called. The server path property does not need to be set in the following instances:

  • Your application is in the same directory as dbmlsync.exe.

  • dbmlsync.exe is in the Windows directory.

Syntax
bool StartServer( unsigned port, const char *cmdline, unsigned timeout, DBSC_Starttype *starttype );
Parameters
  • port    The TCP port to check for an existing dbmlsync server. If a new server is started, it is set to listen on this port.

  • cmdline   A valid command line for starting a dbmlsync server. The command line may contain only the following options which have the same meaning that they do for the dbmlsync utility:

    • -a, -c, -dl, -do, -ek, -ep, -k, -l, -o, -os, -ot, -p, -pc+, -pc-, -pd, -pp, -q, -qi, -qc, -sc, -sp, -uc, -ud, -ui, -um, -un, -ux, -v[cnoprsut], -wc, -wh. See dbmlsync syntax.

    The -c option must be specified.

  • timeout   The maximum time in milliseconds to wait after a dbmlsync server is started for it to be ready to accept requests. Use DBSC_INFINITY to wait forever.

  • starttype   This is an 'out' parameter. If starttype is non-null on entry and StartServer returns true, then on exit the variable pointed to by starttype is set to one of the following values:

    • DBSC_SS_STARTED   Indicates that a new dbmlsync server was started.

    • DBSC_SS_ALREADY_RUNNING   Indicates that an existing dbmlsync server was found, so no new server was started.

Returns

Returns true if the server was already running or was successfully started.

Returns false if the server was not successfully started or the server did not begin processing requests before the timeout expired. When false is returned, you can call the GetErrorInfo method to get more information about the failure. See GetErrorInfo method.