Message Exchange

We have discussed how associations are managed as well as how messages objects are populated and parsed. Now we discuss how these DICOM messages are exchanged with other application entities over the network.

The exchange of DICOM messages between AE's only occurs over an open association. After the DICOM client (SCU) application opens an association with a DICOM server (SCP), the client sends request messages to the server application. For each request message, the client receives back a corresponding response from the server. The server waits for a request message, performs the desired service, and sends back some form of status to the client in a response message. This process, along with the corresponding Merge DICOM Toolkit method calls, are pictured in the following diagram:

The readMessage() method of the MCassociation class is always used to retrieve the next message available on the network connection. Its only parameter is a timeout value which specifies, in milliseconds, how long your process will wait for a message before the read call times out and returns control to your application code. The thread making the call will be blocked during this period. Setting the timeout to 0 is equivalent to polling, since read returns immediately, whether a message has been received or not. A timeout of -1 indicates wait forever, or until a message arrives, before returning. The returned MCreadStatus object encapsulates the result of the read operation.

To send request messages you use the sendRequest() method of the MCAssociation class, and to send response messages you use the sendResponse() method of the same class.

This sendResponse() method allows you to respond to a message received from the remote application. It must be called after a successful readMessage() call. The toolkit automatically identifies which DICOM message is being responded to and fills in the related attribute value.

The status parameter of the sendResponse() method provides the status of the requested operation and must be a valid response code for the service involved. Response codes are defined in the MCresponseStatus class. Many DICOM services do not require a response of more than just a status, others, however, (e.g. C_FIND_RSP) require the setting of several message attributes.