LEADTOOLS DICOM C++ Class Library Help > LEADTOOLS DICOM Features > DICOM Communication > Service Class User (SCU) and Service Class Provider (SCP) > Creating an SCP |
The following steps provide the basic information required to create an SCP:
Initialize the DICOM DLL by calling LDicomNet::StartUp. This must be done before any DICOM Network Operations functions are called. Please note that this only needs to be called once for each application.
Create the DICOM Network object by calling LDicomNet::LDicomNet.
To listen for incoming connection requests, call LDicomNet::Listen.
When an SCU wishes to connect to an SCP, the SCU calls LDicomNet::Connect. This generates a call to the LDicomNet::OnAccept function on the SCP, to let the SCP know that a connection request has been received.
The SCP should respond by calling LDicomNet::LDicomNet and LDicomNet::Accept. Calling LDicomNet::LDicomNet creates a network object for this specific connection and allows the SCP to maintain information about this connection. Calling LDicomNet::Accept will generate a call to the LDicomNet::OnConnect on the SCU. At this time the DICOM Network connection has been established. (An SCP should always accept a connection request. Once the connection is made the SCP can check the SCU and close the connection if it does not wish to maintain it. Since the connection requests are queued, if the connection is not accepted, it remains in the queue. When the next request is received, it is placed in the queue behind the first request. Calling LDicomNet::Accept at this point will connect the first request, not the second, since the first request is still in the queue.)
Establish a security layer. For more information on security layers, refer to Adding Security to a DICOM Connection and Adding TLS Security to a DICOM Connection.
When an SCU requests a DICOM Associate connection, the SCU calls LDicomNet::SendAssociateRequest. This generates a call to LDicomNet::OnReceiveAssociateRequest on the SCP.
When the LDicomNet::OnReceiveAssociateRequest function is called, create the DICOM Associate object by calling LDicomAssociate::LDicomAssociate.
Reset the newly created DICOM Associate object to an Associate Accept by calling LDicomAssociate::Reset, or set the new DICOM Associate handle using the following functions:
LDicomAssociate::SetApplication
LDicomAssociate::SetPresentation
LDicomAssociate::SetImplementClass
LDicomAssociate::SetAsyncOperations
LDicomAssociate::SetRoleSelect
LDicomAssociate::SetImplementVersion
The DICOM Associate connection request can be accepted or rejected. To accept the Associate connection request, call LDicomNet::SendAssociateAccept. This will generate a call to LDicomNet::OnReceiveAssociateAccept on the SCU. At this time the DICOM Associate connection has been established. To reject the Associate connection request, call LDicomNet::SendAssociateReject. This will generate a call to the LDicomNet::OnReceiveAssociateReject function on the SCU.