Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » UltraLite - C 及 C++ 编程 » 应用程序开发 » 使用嵌入式 SQL 开发应用程序 » 向应用程序添加同步

 

设置同步参数

以下代码启动 TCP/IP 同步。MobiLink 用户名是 Betty Best,口令为 TwentyFour,脚本版本为 default,而运行 MobiLink 服务器的主机是 test.internal,端口为 2439

ul_synch_info synch_info;
ULInitSynchInfo( &synch_info );
synch_info.user_name = UL_TEXT("Betty Best");
synch_info.password = UL_TEXT("TwentyFour");
synch_info.version = UL_TEXT("default");
synch_info.stream = ULSocketStream();
synch_info.stream_parms =
   UL_TEXT("host=test.internal;port=2439");
ULSynchronize( &sqlca, &synch_info );

以下代码用于 Palm Computing Platform 上的应用程序,在用户退出应用程序时调用。它允许进行 HotSync 同步,所使用的 MobiLink 用户名为 50、口令为空、脚本版本为 custdb。HotSync 管道通过 TCP/IP 与 MobiLink 服务器进行通信,该服务器运行在管道所在的计算机 (localhost) 上,并使用缺省端口 (2439):

ul_synch_info synch_info;
ULInitSynchInfo( &synch_info );
synch_info.name = UL_TEXT("Betty Best");
synch_info.version = UL_TEXT("default");
synch_info.stream = ULConduitStream();
synch_info.stream_parms =
   UL_TEXT("stream=tcpip;host=localhost");
ULSetSynchInfo( &sqlca, &synch_info );