4.1 Packet Exchanges to Establish the Session

Figure 3: Client establishing the session
The client can establish the session for line device usage by following the steps below:
The Client first calls ClientAttach to establish a binding instance with the server. The method returns 0 on success; otherwise, it returns a nonzero error code.
The Client calls ClientRequest with the Initialize packet to initialize the client's use of TAPI for subsequent use of the line abstraction. The server returns the number of line devices available to the application. The return value of the function is 0 if it is successful and a negative error number if an error occurs.
The client then calls ClientRequest with NegotiateAPIVersionForAllDevices to negotiate which TAPI version to use for which device. The server returns the list of negotiated TAPI and extension versions. The return value of the function is 0 if it is successful and a negative error number if an error occurs.
To get the telephony capabilities of a specified line device, the client calls ClientRequest with GetDevCaps with the device ID. The server returns a packet of LINEDEVCAPS, which is valid for all addresses on the line device. The return value of the function is 0 if it is successful and a negative error number if an error occurs.
To get the telephony capabilities of a specified address on a specific line device, the client calls ClientRequest with GetAddressCaps with the device ID. The server returns a packet of LINEADDRESSCAPS, which is valid for the line address. The return value of the function is 0 if it is successful and a negative error number if an error occurs.
The client then calls ClientRequest with Open to open the line device specified by its device identifier. The server opens the line device and returns a handle for the opened line device. The return value of the function is 0 if it is successful and a negative error number if an error occurs. The values of the parameters for Open depend on the intended purpose and need to refer to the Open packet documentation. For receiving the incoming calls, the LINECALLPRIVILEGE_OWNER bit is set in the dwPrivileges parameter of Open so that the application can own and answer any incoming calls on this line device.