View Full Version : lc_heartbeat Requirements

11-27-2006, 01:24 PM
Does lc_hearbeat require at least a lc_checkout() call for it to work?

A customer has the following code:

/* initialize the job */

if (lc_new_job(0, lc_new_job_arg2, &code, &lm_job))


lc_perror(lm_job, "lc_new_job failed\n");



/* 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);

lc_set_attr(lm_job, LM_A_CKOUT_INSTALL_LIC, (LM_A_VAL_TYPE)0);


/* 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 */

if (lc_checkout(lm_job, FEATURE1, "1.0", 1, LM_CO_NOWAIT, &code, LM_DUP_NONE))


lc_perror(lm_job, "checkout failed\n");

exit (lc_get_errno(lm_job));



Sleep( 1000 );

/* and check it in again */

lc_checkin(lm_job, FEATURE1, 0);


/* start the manual hearbeat timing loop. This loop sends a heartbeat message every iteration */

while (1)


/* when the following call to lc_heartbeat() returns, num_reconnects will contain the number

of sucessful license ser ver system reconnects in the last num_minutes */

/* initialize the job */

if (lc_new_job(0, lc_new_job_arg2, &code, &lm_job2))


lc_perror(lm_job2, "lc_new_job failed\n");



(void)lc_set_attr(lm_job2, LM_A_LICENSE_DEFAULT, (LM_A_VAL_TYPE)LICPATH);

/* set retry count to RETRY_NUM (default is 5, -1 is forever); lc_heartbeat() makes LM_A_RETRY_COUNT

number of connection attempts after license server system connection is lost before calling the

exit handler (defined below) */

lc_set_attr(lm_job2, LM_A_RETRY_COUNT, (LM_A_VAL_TYPE) RETRY_NUM);

if (hbstat = lc_heartbeat(lm_job , &num_reconnects, num_minutes))



The hbstat returns 0 (doesn’t know the license server was down) when the license server was shutdown.

BUT, if he removes the lc_checkin() call between




in the above code segment then hbstat return non-zero (know the license server was down).

Any explanation?


Dai Ngo

11-27-2006, 01:45 PM
From the help topic "How lc_heartbeat Works":
The first heartbeat is sent after the application first connects to the license server system via lc_checkout.(A heartbeat checks the connection to the license server, but the connection isn't established until a license is requested.)

11-27-2006, 01:58 PM
So for lc_hearbeat to work there must be at least one lc_checkout() call (and maintained) to keep the connection between the application and the license server?

There is nothing as such mentioned in the Prog. and Ref. guide.

11-27-2006, 02:56 PM
That topic I referred to, regarding calling lc_checkout first, is in the Programming and Reference Guide under the lc_heartbeat topic.

11-28-2006, 02:33 PM
I believe that's the correct behavior. The heartbeat will be useful only while the license is checked out.

11-29-2006, 12:12 PM
Is it also required for automatic heartbeat to have at least one lc_checkout() call?


11-29-2006, 12:36 PM
According to that "How lc_heartbeat Works" topic mentioned previously, yes, it appears that a call to lc_checkout is required. My understanding is that there is no connection between a job handle and a specific license server until a checkout occurs, and lc_heartbeat and automatic heartbeats are used to monitor such a connection.