...
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Options
...
Option | Comment |
Option name | Comment |
Example
...
Code Block | ||
---|---|---|
| ||
#define S_MAXDIFF 30 /* Check if the clocks on two servers are unsyncronized beyond a threshold value */ EdmiError rstat; SdaiServerContext tellusContext, saturnContext; EdmiPackedDate tellusPackedDate, saturnPackedDate, dateDiff; EdmiDate tellusDate, saturnDate; EdmiStringDate tellusStringDate, saturnStringDate; SdaiUnsignedInt tellusSeconds, saturnSeconds; /* Create a Tellus server context */ rstat = edmiDefineServerContext("TellusContext", "superuser", NULL, "xfx56kl9", "TCP", "9090", "Tellus", NULL, NULL, NULL, NULL, NULL, &tellusContext); /* Create a Saturn server context */ rstat = edmiDefineServerContext("SaturnContext", "superuser", NULL, "xgg45k22", "TCP", "9095", "Saturn", NULL, NULL, NULL, NULL, NULL, &saturnContext); /* Read the clock on server Tellus */ rstat = edmiRemoteGetDate(tellusContext, &tellusPackedDate, &tellusDate, &tellusStringDate, 0, NULL); /* Read the clock on server Saturn */ rstat = edmiRemoteGetDate(saturnContext, &saturnPackedDate, &saturnDate, &saturnStringDate, 0, NULL); printf("\nMaster time is (Tellus):"); printf("\n Year ..............: %d", tellusDate.year); printf("\n Month .............: %d", tellusDate.month); printf("\n Day .............. : %d", tellusDate.day); printf("\n Hour ..............: %d", tellusDate.hour); printf("\n Minute ............: %d", tellusDate.minute); printf("\n Second ............: %d", tellusDate.second); printf("\n WeekDay ...........: %d", tellusDate.weekday); printf("\n Day of Year .......: %d", tellusDate.dayOfYear); printf("\n daylightSavingTime : %d", tellusDate.daylightSavingTime); if (tellusDate.dayOfYear != saturnDate.dayOfYear) { _sleep(S_MAXDIFF*1000); } tellusSeconds = 3600 * tellusDate.hour; tellusSeconds += 60 * tellusDate.minute; tellusSeconds += tellusDate.second; saturnSeconds = 3600 * saturnDate.hour; saturnSeconds += 60 * saturnDate.minute; saturnSeconds += saturnDate.second; dateDiff = saturnSeconds - tellusSeconds; if (abs(dateDiff) > S_MAXDIFF) { printf("\n\nWARNING!!! Unsyncronized server clocks."); printf("\nSaturn is %d seconds %s Tellus", abs(dateDiff), (dateDiff > 0) ? "ahead of" : "behind"); } else { printf("\nServer clocks are syncronized."); printf("\n - Saturn drift is %d seconds", dateDiff); } . . . |
...