Skip to content

Commit

Permalink
[dcmnet] Extend DcmSCU::negotiateAssociation to take a cancel token a…
Browse files Browse the repository at this point in the history
…s argument

We'll use this cancel token to cancel ongoing TCP connect attempts. A cancel token
allows the client to decide how a request should be cancelled, for example using
std::stop_token in the implementation of the ICancelToken.
  • Loading branch information
100029962 committed Apr 17, 2023
1 parent 109ec54 commit 1bd0e8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion dcmnet/include/dcmtk/dcmnet/scu.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ class DCMTK_DCMNET_EXPORT RetrieveResponse : public QRResponse
RetrieveResponse& operator=(const RetrieveResponse& other);
};

class IDcmCancelToken
{
public:
virtual ~IDcmCancelToken() {}
virtual bool IsCanceled() const = 0;
};

/** Base class for implementing DICOM Service Class User functionality. The class offers
* support for negotiating associations and sending and receiving arbitrary DIMSE messages
* on that connection. DcmSCU has built-in C-ECHO support so derived classes do not have to
Expand Down Expand Up @@ -226,7 +233,7 @@ class DCMTK_DCMNET_EXPORT DcmSCU
* @return EC_Normal if negotiation was successful, otherwise error code.
* NET_EC_AlreadyConnected if SCU is already connected.
*/
virtual OFCondition negotiateAssociation();
virtual OFCondition negotiateAssociation(IDcmCancelToken* tcpCancelToken = NULL);

/** After negotiation association, this call returns the first usable presentation context
* given the desired abstract syntax and transfer syntax
Expand Down
2 changes: 1 addition & 1 deletion dcmnet/libsrc/scu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ OFCondition DcmSCU::initNetwork()
return cond;
}

OFCondition DcmSCU::negotiateAssociation()
OFCondition DcmSCU::negotiateAssociation(IDcmCancelToken* tcpCancelToken)
{
/* Return error if SCU is already connected */
if (isConnected())
Expand Down

0 comments on commit 1bd0e8b

Please sign in to comment.