# mspDisconnect

Disconnects a media channel between two MSPP endpoints.

#### Prototype

DWORD mspDisconnect ( MSPHD ephd1, MSPHD chnhd, MSPHD ephd2 )

Argument | Description
ephd1 | First MSPP endpoint handle.
chnhd | MSPP channel handle.
ephd2 | Second MSPP endpoint handle.

#### Return values

Return value | Description
SUCCESS |
CTAERR_BAD_ARGUMENT | Function argument includes an invalid value or a required pointer argument is NULL.
CTAERR_INVALID_CTAHD | Handle is invalid.
CTAERR_INVALID_HANDLE | Invalid handle was passed as an argument to this function.
MSPERR_CHANNEL_NOT_CONNECTED | The specified MSPP channel is not connected to any endpoints.
MSPERR_DRIVER_COMMAND_FAILED | An SPI command has failed.
MSPERR_INTERNAL_HANDLE | Specified MSPP endpoint/channel is not valid.
MSPERR_INVALID_CONNECTION | Specified MSPP connection cannot be found.
MSPERR_INVALID_HANDLE | Specified MSPP endpoint/channel is not valid.

#### Events

Event | Description
MSPEVN_DISCONNECT_DONE | Generated when an MSPP channel is disconnected from two endpoints in response to an mspDisconnect function call. The event.value field can contain the following: CTA_REASON_FINISHED MSPRSN_FAILED_TO_DEALLOCATE MSPP service is unable to deallocate on-board resources. MSPRSN_FAILED_TO_INTRADISCONNECT MSPP service is unable to disconnect filters within the channel. MSPRSN_FAILED_TO_INTERDISCONNECT MSPP service was unable to disconnect the channel from an endpoint. The event.objHd indicates the chnhd of the disconnected channel.

#### Details

When called, mspDisconnect disassociates the MSPP endpoints and MSPP channel in a specified connection. The application specifies endpoint handles in the same order it used when creating the connection with mspConnect.

For example, in the case of voice channels, ephd1 must point to an RTP endpoint and ephd2 must point to a DS0 endpoint. In the case of fax channels, ephd1 must point to a UDP endpoint (for fax) and ephd2 must point to a DS0 endpoint. The application must disable channels and endpoints associated with the connection (using mspDisableChannel and mspDisableEndpoint) before using mspDisconnect.

#### See also

mspConnect

#### Example

ret = mspDisconnect( hEp1, hChan, hEp2);
if (ret != SUCCESS)
return FAILURE;
// Wait for event
ctaWaitEvent( hCtaQueHd, &Event, CTA_WAIT_FOREVER );
// Check the reason code
if ( Event.id != MSPEVN_DISCONNECT_DONE ||
Event.value != CTA_REASON_FINISHED )
return FAILURE;