This is how i did this. I used the PingOnly option in sync params. try { ULCreateParms createParms = new ULCreateParms(); createParms.CaseSensitive = true; createParms.UTF8Encoding = true; ULConnectionParms openParms = new ULConnectionParms(); string appPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath); string testPingDbFileName = System.IO.Path.Combine(appPath, "ping.udb"); openParms.DatabaseOnDesktop = testPingDbFileName; if (System.IO.File.Exists(testPingDbFileName) == false) { iAnywhere.Data.UltraLite.ULDatabaseManager.CreateDatabase( openParms.ToString(), createParms.ToString() ); } ULConnection cn = new ULConnection(openParms.ToString()); cn.Open(); cn.SyncParms.PingOnly = true; cn.SyncParms.UserName = "sa"; cn.SyncParms.Stream = ULStreamType.HTTP; cn.SyncParms.StreamParms = string.Format("host={0};port={1}",mobilinkServer,mobilinkPort); cn.SyncParms.Version = mobilinkVersion; cn.Synchronize(); object a = cn.SyncResult; cn.Close(); isOnline = true; } catch (Exception ex) { isOnline = false; } |
Would the SQL Anywhere monitor be an option? "The SQL Anywhere Monitor, also referred to as the Monitor, is a browser-based administration tool that provides you with information about the health and availability of SQL Anywhere databases (including databases in read-only scale-out and mirroring systems), MobiLink servers, MobiLink server farms, and Relay Server farms." I want to implement it in my application, not to use any other monitoring tools. In a period of time to try to sync or to ping and see if there is connection to the server, if there is not a connection to show the user who is working a message.
(17 Apr '12, 10:54)
katalun4o
|
I guess the ML client ping utility will do: dbmlsync -pi -c connection_string ... Apparently, the DbmlSync .NET API has a 1
The Ping method in the dbmlsync client API (either the C++ or .NET implementation) is a ping of the dbmlsync process, and not the MobiLink Server. If you are using a SQL Anywhere remote, then dbmlsync -pi is perfect, and if you are using UltraLite, setting the "ping" member of the synch info class you pass to the Synchronize function will perform a minimal connection to the MobiLink Server.
(17 Apr '12, 13:18)
Reg Domaratzki
|
In addition to Volker's comments, and you're using SQL Anywhere 12, you could also launch "mlreplay -ping seconds" from your application and check the return code for the utility:
Another API alternative is to use the DBTools DBSynchronizeLog function, and pass in a "a_sync_db" structure with the "ping" struct member set to "TRUE". See: http://dcx.sybase.com/index.html#1201/en/mlclient/mc-dbtools.html. |