Connect to the specified iSeries™ host service.
UINT CWB_ENTRY cwbCO_Connect( cwbCO_SysHandle system, cwbCO_Service service, cwbSV_ErrHandle errorHandle );
The following list shows common return values.
If signon to the iSeries system has not yet occurred, the signon will be performed first when cwbCO_Connect is called. If you want the signon to occur at a separate time, call cwbCO_Signon first, then call cwbCO_Connect at a later time. For more information about signon and its behavior, see comments for cwbCO_Signon. If the signon attempt fails, a connection to the specified service will not be established.
If the iSeries system as named in the specified system object does not exist in the System List, and the system object Persistence Mode is set appropriately, then when cwbCO_Connect or cwbCO_Signon is first successfully called, the iSeries system, as named in the system object, will be added to the System List. For more information about the Persistence Mode, see the comments for cwbCO_SetPersistenceMode.
If a connection to the specified service already exists, no new connection will be established, and CWB_OK will be returned. Each time this API is successfully called, the usage count for the connection to the specified service will be incremented.
Each time cwbCO_Disconnect is called for the same service, the usage count will be decremented. When the usage count reaches zero, the actual connection is ended.
Therefore, it is VERY IMPORTANT that for every call to the cwbCO_Connect API there is a later paired call to the cwbCO_Disconnect API, so that the connection can be ended at the appropriate time. The alternative is to call the cwbCO_Disconnect API, specifying CWBCO_SERVICE_ALL, which will disconnect all existing connections to ALL services made through the specified system object, and reset all usage counts to 0.
If the return code is CWB_USER_TIMEOUT, you may want to increase the connect timeout value for this system object, by calling cwbCO_SetConnectTimeout, and try connecting again. If you want iSeries Access to not give up until the TCP/IP communication stack itself does, set the connect timeout to CWBCO_CONNECT_TIMEOUT_NONE, and try connecting again.