Summary
This article contains how to write a MANUAL HEARTBEAT example.
Synopsis
NOTE: This example is from Manual Heartbeat Example on pages 45-47 of the FlexNet Publisher 11.6.1 Programming Reference for License File-Based Licensing, ProgRef-LF.pdf.
The code sequence below demonstrates one way to implement manual heartbeats; it uses the FLEXible API. This example incorporates the manual heartbeat timing loop within the main routine of the application, with the intention that application code be included within this timing loop.
#include "lmclient.h"
#include "lm_attr.h"
VENDORCODE code;
LM_HANDLE *lm_job;
int num_reconnects; /* parameter to lc_heartbeat() */
int num_minutes; /* parameter to lc_heartbeat() */
int hbstat; /* return status for lc_heartbeat() */
int exitcall(char *); /* exit handler callback */
void
main(int argc, char * argv[])
{
/* Initialize the job */
if (lc_new_job(0, lc_new_job_arg2, &code, &lm_job))
{
lc_perror(lm_job, "lc_new_job failed");
exit(lc_get_errno(lm_job));
}
/* Turn off automatic heartbeat timing. */
lc_set_attr(lm_job, LM_A_CHECK_INTERVAL, (LM_A_VAL_TYPE) -1);
lc_set_attr(lm_job, LM_A_RETRY_INTERVAL, (LM_A_VAL_TYPE) -1);
/* Set retry count to 3 (default is 5); lc_heartbeat() makes
LM_A_RETRY_COUNT number of reconnection attempts after
license server connection is lost before calling the
exit handler (defined below).*/
lc_set_attr(lm_job, LM_A_RETRY_COUNT, (LM_A_VAL_TYPE) 3);
/* Register the exit handler callback, "exitcall." The default is
the system?s exit routine. */
lc_set_attr(lm_job, LM_A_USER_EXITCALL, (LM_A_VAL_TYPE) exitcall);
/* Check out the feature, "f1." */
if (lc_checkout(lm_job, "f1", "1.0", 1, LM_CO_NOWAIT, &code, LM_DUP_NONE))
{
lc_perror(lm_job, "checkout failed");
exit (lc_get_errno(lm_job));
}
/* Start the manual heartbeat timing loop. This loop
sends a heartbeat message with every iteration. */
while (1)
{
/* When the following call to lc_heartbeat() returns,
num_reconnects will contain the number of successful
license server reconnects in the last num_minutes.
*/
if (hbstat = lc_heartbeat(lm_job, &num_reconnects, num_minutes))
{
/* Connection to license server is lost and an attempt to
reconnect unsuccessful. Monitor hbstat
and respond as appropriate to your license policy.
After LM_A_RETRY_COUNT number of reconnect attempts,
3 in this example, control automatically transfers to
the exit handler, "exitcall." */
}
/* Loop timing and application code for this license job
occur here. */
} /* end of heartbeat timing loop */
lc_checkin(lm_job, feature ,0);
lc_free_job(lm_job);
exit(0);
}
/* Exit handler callback. This is invoked automatically by
after five consecutive reconnection attempts are made
to a lost license server. */
int
exitcall(char * feature)
{
printf("I am in the exit callback for feature %s\n", feature);
exit(1);
}Related Articles
Problem building FlexNet Publisher 11.6.1 csharp sample application 'out of the box' 3Number of Views FlexNet Publisher C# Sharp Example Instructions 8Number of Views Elevated Privilege Issue with FlexNet Publisher Licensing Service on Windows 9Number of Views FlexNet Publisher versus FlexNet Embedded license server 18Number of Views FlexNet Publisher 2014 R2 SP3 (11.13.0.3) Release Notes 6Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Revenera Assistant
Case id: 00001065
Activity: Status change: 2 hours ago