from the commands. Control returns to the application when the connection is established and Sterling Connect:Direct is ready for the first API request or when an error condition is set.

Following is the format for the ndmapi_connect() or ndmapi_connect_c() function:

int32 ndmapi_connect ERROR_H error, char * ndm_hostname, char * ndm_portname

The following table describes the parameters for the ndmapi_connect() or ndmapi_connect_c() function:

Parameter

Description

Value

 

 

 

error

A pointer to a Sterling Connect:Direct-defined structure

Pointer

 

that contains error information or status information.

 

 

 

 

ndm_hostname

A pointer to the text specification of the Sterling

Null-

 

Connect:Direct host to which the connection is made. If

terminated

 

this parameter is not specified, the host name is

string

 

determined by first checking the environment variable

 

 

TCPHOST. If no value is specified, the tcp.host.name

 

 

field in the CLI/API configuration file is checked. If no

 

 

value is specified, the gethostbyname() command is

 

 

invoked and the default value of ndmhost is used.

 

 

 

 

ndm_portname

A pointer to the host port number. If this parameter is

Pointer

 

not specified, the environment variable TCPPORT is

 

 

checked. If no value is specified, the value of the

 

 

tcp.port in the CLI/API configuration file is checked. If

 

 

no value is specified, the default value 1363 is used.

 

 

 

 

The ndmapi_connect() or ndmapi_connect_c() function has the following return codes:

Parameter

Description

 

 

NDM_NO_ERROR

A session was established with the server.

 

 

NDM_ERROR

A session was not established with the

 

server. Consult the error structure for

 

detailed error status.

 

 

The following sample function illustrates the use of ndmapi_connect() to connect to the sun1 host:

rc=ndmapi_connect (error, "sun1", "3122");

Terminating a Connection Using ndmapi_disconnect() or ndmapi_disconnect_c()

Use ndmapi_disconnect() or ndmapi_disconnect_c() to terminate a connection to Sterling Connect:Direct that was established by a call to ndmapi_connect() or ndmapi_connect_c(). The ndmapi_disconnect() or ndmapi_disconnect_c()function call is the following:

void ndmapi_disconnect

There are no parameters and no return codes for ndmapi_disconnect() or ndmapi_disconnect_c(). Following is a sample ndmapi_disconnect() function:

ndmapi_disconnect ();

Chapter 4. Writing Custom Programs 63

Page 69
Image 69
IBM 4J manual Ndmnoerror, Ndmerror