QLIB-function: QAPIConnect


Connects the QLIB to a QLIB Remote Server over a TCP/IP connection.

ULONG QAPIConnect ( char* ip, ULONG port, char* username, char* password, ULONG timeout );


Parameter 1
ip
The IP address of the remote machine. Each IP address is denoted by what is called dotted decimal notation ( i.e. 192.168.5.1 ) or by it's fully qualified domain name (i.e. tiger.dyndns.org).

Parameter 2:
port
The port number. The TCP layer requires what is called a port number to be assigned to each connection.
The port number must be equal to the port number which is configured in the QLIB Server.

Parameter 3:
username
Username used to login configured in the QLIB Server Usermanager.

Parameter 4:
password
Password used to login configured in the QLIB Server Usermanager.

Parameter 5:
timeout
The timeout value in milliseconds ( i.e.1000 = 1s, 2000 = 2s ...).The time between each QAPIxxxx function call must be less then the specified timeout intervall. If the time is longer, the client will teminate the session and a call to QAPIGetLastError on the client side will return the error "ERROR_QLIB_CONNECTION_TIMEOUT".

Return value
If the function succeeds, the return value is 1. This switches the client QLIB to the "Remote" mode. If the function fails, the return value is 0.

Commands
Call the function QAPIGetLastError to get information why the function failed. If QAPIConnect fails, the QLIB stays in "Local" mode.

There are two modes the QLIB can have. First mode is "Local" which is the default mode. In this mode all QAPIxxxx commands will route to the local hardware. Second mode is "Remote" which will route all QAPIxxxx functions, except QAPIConnect() and QAPIDisconnect(), to a remote QLIB Server. The QLIB Server will execute the requested QAPIxxxx functions on it's own local hardware.

Which mode (local or remote) is currently active can be determined by the QAPIGetConnectionMode function. If the QLIB has entered the "Remote" mode, the only reason why it switches back to "Local" mode is, that the QLIB Client program has called the QAPIDisconnect function. Network errors or terminations or other faults will not switch the QLIB back to "Local" mode. Instead of this, the function QAPIGetLastError will return the error "ERROR_QLIB_CONNECTION_DISCONNECTED". This behavior is to prevent QLIB from extecuting QAPIxxxx functions on the local machine in case of any error.

 Back to the QLIB overview