UCM Unitec Home Page
      

Get UCM Version

 UcmVersion(F)

Synopsis   Environment   Description   Diagnostics   Notes   See also   Examples

Synopsis

#include "ucm.h"

int UcmVersion();

int UcmClientVersion(sock, timeOut);
T_SOCKET sock;
unsigned int timeOut;

Environment

Unix, Win32

Description

UcmVersion returns the current version number of the UCM library used to link the program. The version integer contains the sum of the major release number multiplied by 100 and the minor release number, i.e. release 2.03 will be returned as 203.

UcmClientVersion returns the current version number of the UCM Active-X control or the UcmConnect library function used to establish the socket sock with the caller. Starting with release 2.03 the client logic of UCM sends an internal version information message immediately after establishing a socket connection and before transmission of any application data. If this internal message is not received within timeOut milliseconds or any application data is received without prior internal version information, a value of 0 (zero) will be returned, indicating an unknown version. It is usually safe to use a large value (e.g. 20'000) as timeOut argument.

It is best to assume UCM 1.0 (formerly named UDM) if the UcmClientVersion function returns zero.

Both version functions may be used prior a call to UcmInit.

UcmClientVersion will fail and no version information will be returned if one or more of the following is true:

UE_BADSOCK The value of sock is not a valid socket descriptor or the socket is not open.
UE_INTR The read process of the internal version message has been interrupted by a signal.
UE_CONNECT The socket has been closed.

Diagnostics

Upon successful completion UcmVersion and UcmClientVersion both return a version integer value as described above. Otherwise, UCM_ERROR is returned and ucmErrno is set to indicate the error.

Notes

The version functions have been introduced in release 2.03. The use of the UcmClientVersion function with socket arguments created by older UCM clients will return a version value of 0 (zero), indicating an unknown version.

See also

UcmConnect

Examples

 
#include "ucm.h"

main(argc, argv)

int argc;
char *argv[];
{
    int version;            /* client version */
    T_SOCKET sock;          /* socket from argv[1] */

    ucmProgName = argv[0];  /* for UCM error msgs */
    sock = atoi(argv[1]);
    version= UcmClientVersion(sock, 10000);
    UcmInit();
    if (UcmOpen(sock))
        Error("UcmOpen failed, error=%d", ucmErrno);
    if (version >= 200)
        UcmCntl(sock, UC_KEEPALIVE, 120, 10);
    while ((len = UcmRecv(sock, msgId, msg,
                                -1, UF_NOFLAGS)) > 0)
    {
        /* process incoming message */
        if (strcmp(msg, "Exit") == 0)
            break;
        UcmSendf(sock, msgId, "Got: %s", msg);
    }
    UcmClose(sock);
    UcmTerm();
    return 0;               /* terminate program */
}

 

Back to top