Creating a Connection to IBM Connect:Direct Using ndmapi_connect() or ndmapi_connect_c()

Use ndmapi_connect() or ndmapi_connect_c() to create a connection to IBM® Connect:Direct® so that an application can send commands and receive responses from the commands. Control returns to the application when the connection is established and IBM 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 IBM Connect:Direct-defined structure that contains error information or status information. Pointer
ndm_hostname A pointer to the text specification of the IBM Connect:Direct host to which the connection is made. If this parameter is not specified, the host name is 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. Null-terminated string
ndm_portname A pointer to the host port number. If this parameter is 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. Pointer

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");