UCM Unitec Home Page
      

Connect to an UCM Server

 UcmConnect(F)

Synopsis   Environment   Description   Diagnostics   Globals   Notes   See also   Examples

Synopsis

#include "ucm.h"

T_SOCKET UcmConnect(host, service);
char *host;
char *service;

Environment

Unix, Win32

Description

UcmConnect opens and initializes a BSD stream type socket to the server identified by service on the node host. There is no need for a client process to call UcmOpen, since UcmConnect implies all necessary initializations. Before terminating a process that has successfully called this function, UcmClose should be called to properly release the socket. The host argument represents the TCP/IP address or host name on which the server process providing the service is located. When using the symbolic host name, it must be defined in /etc/hosts or the Windows hosts file. The second argument identifies the service that the socket will be assigned to. Service may be given as symbolic TCP/IP service name or as numeric port number. When using the symbolic service name, it must be defined in /etc/services or the Windows services file with type ftp.

UcmConnect will fail if one or more of the following is true:

UE_NOTINIT The UCM software has not been initialize (see UcmInit)
UE_INVALID Invalid argument.
UE_HOST The value host does not identify a known host.
UE_SERVICE The value service does not identify a known service.
UE_BADSOCK The operating system returned a bad status while creating a new socket.
UE_CONNECT The given host does not provide the requested service.
UE_NOMEM The new socket could not be entered into the internal database, due to low memory.
UE_NOMSG The initialization handshaking with the server failed.
UE_ULMREG The product UCM is not registered in the license database. Enter your activation key in the ulm(I) utility.
UE_ULMEXP The UCM license has expired. This error may occur in demo versions only.
UE_ULMBUSY Too many users. The UCM license does not allow additional users at this time. Please consult Unitec for details on how to increase your license.

Diagnostics

Upon successful completion UcmConnect returns a valid socket number. Otherwise, UCM_ERROR is returned and ucmErrno is set to indicate the error.

Globals

char *ucmProgName;    /* reference */

Notes

UcmConnect sets the linger options of socket to:

l_onoff = TRUE;
l_linger = 30;

For a detailed description of these options see setsockopt(2), so_linger. If your application needs different settings, these should be made after the call to UcmConnect.

The global pointer char *ucmProgName, which is defined in ucm.h and allocated in libucm.a, may optionally be set to the program name of the calling task. This string will be used to identify possible messages on stderr. If ucmProgName is not set, the default string ‘UCM Library’ will be used.

See also

UcmInit, UcmClose, UcmTerm, hosts(4), services(4)

Examples

 
#include "ucm.h"

T_SOCKET sock;
...
UcmInit();
sock = UcmConnect("128.41.01.01", "6001");
...
UcmClose(sock);
UcmTerm();

 

Back to top