For local features, the LMX_Heartbeat function checks whether HostIDs are valid. Note that devices such as dongles can be removed during runtime.

For network features, in addition to checking HostIDs, the LMX_Heartbeat function checks whether the network connection to the license server is working.

Prototype

LMX_STATUS LMX_Heartbeat
(
   LMX_HANDLE LmxHandle,
   const char *szFeatureName
);

Parameters

LmxHandle
[in/out] LM-X handle.

Return values

On success (when local HostIDs are valid and, for network licenses, when the license server connection is up), this function returns the status code LMX_SUCCESS. Features that do not require HostID checks (borrow, trial, and grace) always return LMX_SUCCESS.

On failure (one or more local HostIDs are invalid or the license server is down or otherwise unreachable), this function returns an error code in the format described in Return codes.

If you call this function on a feature that does not exist, it will return LMX_FEATURE_NOT_FOUND.

Remarks

There is no need to call this function for network licenses if you are using automatic heartbeats. (Note that automatic heartbeats are for network licenses only.)

LMX_Heartbeat should be called in increments of between 30 seconds and 2 minutes. If you call it more often than this, it will return the last cached result.

If heartbeats fail, the client can attempt to make a transparent connection to another server by going through a list of all known servers.

If the license is lost, LMX_Heartbeat will return LMX_HEARTBEAT_LOST_LICENSE. In the case of a lost license, the client must perform a checkin and then a checkout to continue using the license.

Example
After a checkin of the feature "f2", the LMX_Heartbeat function checks whether "f2" connection to the license server is working; for local licenses, LMX_Heartbeat checks whether HostIDs are still valid, as shown below.

#include <lmx.h>
#include <stdio.h>
 
LMX_HANDLE h;
 
int main() {
  exit_on_error(LMX_Init(&h));
  exit_on_error(LMX_Checkout(h, "f2", 1, 0, 1));
  exit_on_error(LMX_Heartbeat(h, "f2"));
  return 0;
}

The following example shows how to set an automatic heartbeat with the heartbeat frequency set for 60 seconds.

#include <lmx.h>
#include <stdio.h>

LMX_HANDLE h;

int main() {
  exit_on_error(LMX_Init(&h));
  exit_on_error(LMX_SetOption(h, LMX_OPT_AUTOMATIC_HEARTBEAT_ATTEMPTS, (LMX_OPTION) 1));
  exit_on_error(LMX_SetOption(h, LMX_OPT_AUTOMATIC_HEARTBEAT_INTERVAL, (LMX_OPTION) 60));
  return 0;
}